bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difference between EPOCHREALTIME and EPOCHSECONDS


From: felix
Subject: Difference between EPOCHREALTIME and EPOCHSECONDS
Date: Tue, 14 Apr 2020 10:41:36 +0200

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 . 999940
          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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]