|Pathologically Eclectic Rubbish Lister|
Time::HiRes gettimeofday producing timestamps out of orderby 1nickt (Abbot)
|on May 06, 2016 at 13:30 UTC||Need Help??|
1nickt has asked for the wisdom of the Perl Monks concerning the following question:
I am using Time::HiRes to create timestamps in my program which I insert into the DB with the record, rather than using the DB's timestamp function, because of the unpredictability of when the record might actually be inserted.
In my logger:
which is called, sequentially, three times, with actions 'finish', 'sleep', 'complete'.
Most of the time the results are as expected, but sometimes the order is off. Example (note that the DB insert IDs follow the order of the program):
Now I have read up on Time::HiRes and the various gotchas that occur related to the system clock. But I don't get this because (a) the code is doing the calls sequentially (b) the DB is inserting the rows in the same sequence, but (c) the timestamps are not in the same order.
Any help to understand what's going on here would be greatly appreciated.
The way forward always starts with a minimal test.