Difference between EPOCHREALTIME and EPOCHSECONDS

2020-04-14 Thread felix
Configuration Information:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux medium 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) 
x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 16
Release Status: release

Description:
Integer part of $EPOCHREALTIME could increase more than 8000 
microseconds
before $EPOCHSECONDS

Repeat-By:
epochVariableDiff () {
local errcnt=0 lasterrcnt v1 v2 v3 us vals line
while ((errcnt==0)) || ((errcnt>lasterrcnt)); do
lasterrcnt=$errcnt
printf -v vals '%(%s)T %s %s' -1 $EPOCHSECONDS $EPOCHREALTIME
IFS=$' .' read v1 v2 v3 us <<<"$vals"
[ "$v1" = "$v2" ] && [ "$v2" = "$v3" ] || ((errcnt++))
[ $errcnt -eq 1 ] && echo "$line"
printf -v line '%3d %s - %s - %s . %s' $errcnt $v1 $v2 $v3 $us
printf "%s\r" "$line"
((errcnt)) && echo "$line"
read -t ${1:-.0002}
done

epochVariableDiff
  0 1586853481 - 1586853481 - 1586853481 . 40
  1 1586853481 - 1586853481 - 1586853482 . 000320
  2 1586853481 - 1586853481 - 1586853482 . 000691
  3 1586853481 - 1586853481 - 1586853482 . 001059
  4 1586853481 - 1586853481 - 1586853482 . 001429
  5 1586853481 - 1586853481 - 1586853482 . 001854
  6 1586853481 - 1586853481 - 1586853482 . 002220
  7 1586853481 - 1586853481 - 1586853482 . 002672
  8 1586853481 - 1586853481 - 1586853482 . 003113
  9 1586853481 - 1586853481 - 1586853482 . 003530
  9 1586853482 - 1586853482 - 1586853482 . 003889

(My raspberry-pi seem not to be affected)

Was discovered and published at 
https://stackoverflow.com/a/58557346/1765658



Re: Difference between EPOCHREALTIME and EPOCHSECONDS

2020-04-14 Thread Chet Ramey
On 4/14/20 4:41 AM, fe...@f-hauri.ch wrote:

> Bash Version: 5.0
> Patch Level: 16
> Release Status: release
> 
> Description:
> Integer part of $EPOCHREALTIME could increase more than 8000 
> microseconds
> before $EPOCHSECONDS

It's the difference between time() and gettimeofday().

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: Difference between EPOCHREALTIME and EPOCHSECONDS

2020-04-14 Thread Martin Schulte
Hello Chet, hello Felix, hello all!

> > Bash Version: 5.0
> > Patch Level: 16
> > Release Status: release
> > 
> > Description:
> > Integer part of $EPOCHREALTIME could increase more than 8000
> > microseconds before $EPOCHSECONDS
> 
> It's the difference between time() and gettimeofday().

I didn't believe it ;-) but running

time_gettimeofday.c:

#include 
#include 
#include 

int main(int argc, char *argv[]) {
  struct timeval tv;
  time_t t;
  struct timespec sleep;
  sleep.tv_sec = 0;
  sleep.tv_nsec = 100;
  for (int i=0; i<1001; i++) {
gettimeofday(&tv, NULL);
t = time(NULL);
printf("%d.%.6d %d %d\n", tv.tv_sec, tv.tv_usec, t, tv.tv_sec-t);
nanosleep( &sleep, NULL );
  }
  return 0;
}

with 

gcc -o time_gettimeofday time_gettimeofday.c && ./time_gettimeofday |
  egrep '\.(00|99)

shows it is right...

Thanks and best regards,

Martin



Re: Difference between EPOCHREALTIME and EPOCHSECONDS

2020-04-14 Thread Chet Ramey
On 4/14/20 1:43 PM, Martin Schulte wrote:
> Hello Chet, hello Felix, hello all!
> 
>>> Bash Version: 5.0
>>> Patch Level: 16
>>> Release Status: release
>>>
>>> Description:
>>> Integer part of $EPOCHREALTIME could increase more than 8000
>>> microseconds before $EPOCHSECONDS
>>
>> It's the difference between time() and gettimeofday().

EPOCHSECONDS is the analog of SECONDS, with the difference being the
starting point.

EPOCHREALTIME is supposed to be the thing you use if you want additional
precision than seconds granularity.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: [PATCH] Add active mark, face support; activate mark on paste

2020-04-14 Thread Chet Ramey
On 4/14/20 4:46 PM, gentoo_esh...@tutanota.com wrote:
> Another 'face' issue(the 3rd?) I just noticed now:
> if I paste something that has "\n" inside it, like these 3 lines(only the 
> first 2 lines have \n, but doesn't matter):
> -bash: mk_add_options: command not found
> -bash: mk_add_options: command not found
> -bash: mk_add_options: command not found
> 
> then they are all pasted on the same line, so I have to manually press Enter 
> to execute the line.

This is the expected behavior with bracketed-paste enabled. The pasted text
is `bracketed' by a start and end sequence -- that's how the face code
knows what's been pasted and to highlight it -- and any embedded editing
characters, like newline, are simply added to the editing buffer. The
face code enables bracketed paste by default, since it doesn't make much
sense to test it without bracketed paste enabled.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/