in reply to Re: The most precise second (timer)
in thread The most precise second (timer)
haukex, you’re the closest to understanding my problem and possibly to give me a solution!
Well, on the chronyd stuff: I am running chronyd service, but not running ntpd (which is not even installed on particular system), see bellow.
$ systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; v +endor preset: enabled) Active: active (running) since Wed 2019-10-23 13:38:15 CEST; 1 mont +hs 4 days ago Docs: man:chronyd(8) man:chrony.conf(5) Main PID: 8102 (chronyd) CGroup: /system.slice/chronyd.service └─8102 /usr/sbin/chronyd Warning: Journal has been rotated since unit was started. Log output i +s incomplete or unavailable. $ systemctl status ntpd Unit ntpd.service could not be found.
I still need to delve into the chronyd docs.
Is this interpretation of your problem correct?
Well, kind of. We’d like to monitor some stuff each and every second. In the perfect world, this would mean that each and every real second a script would run, get data and insert in into the DB. As we don’t want/need to use atomic clock (etc), therefore by the real second we mean a second as precice accurate as possible. … In the end, you are probably right about the interpretation. ;)
So if sleep is not the right tool for the job, what would it be? And why does the EV (my $w2 = EV::periodic( 0, 1, 0, sub { print Math::BigFloat->new( sprintf("%d.%06d",gettimeofday) ), "\n";} );) seconds diff is greater than the original code (below is simplified version of the original code; on my computer it has diff bellow 0.0004, sometimes the avg is 0.0002)?
use strict; use warnings; use Time::HiRes qw/time sleep/; sub negative_timer { my $max = $_[0]; my @time_test; my $start = time(); for (my $i = 0; $i < $max; $i++) { $start += 1; sleep $start - time(); $time_test[$i] = time(); } return @time_test; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: The most precise second (timer)
by haukex (Archbishop) on Nov 27, 2019 at 15:54 UTC | |
by tukusejssirs (Beadle) on Nov 27, 2019 at 22:08 UTC | |
by haukex (Archbishop) on Nov 27, 2019 at 23:29 UTC | |
by tukusejssirs (Beadle) on Nov 28, 2019 at 11:33 UTC |