I was calculating orbital elements once per second with Perl and noticed a glitch that occasionally doubled one of the derivatives for a single second.

I was using the core function "time" and noticed that the unixtime stamp would skip a second just before the event would occur.

Then I tried to see more with Time::HiRes and saw that a second would be skipped when the decimal turned over.

I ran these two lines of code concurrently in bash shells, and saw the strange results:


perl -le 'while () { print time; sleep 1 }'

1579941920
1579941921
1579941922
1579941924 <- WTF?

perl -MTime::HiRes=time -le 'while () { print time; sleep 1 }'

1579941920.99577
1579941921.99751
1579941922.99824
1579941924.00213 <- WTF!

A third terminal running at the same time printed the missing second, but, it skipped one when it eventually turned over.
1579941920.51386
1579941921.51823
1579941922.52046
1579941923.52163 <- OK
1579941924.52477
The interval does not seem significant:
1579941920.99577
1.00174
1579941921.99751
1.00073
1579941922.99824
1.00389
1579941924.00213 <- WTF!
I tried a lot of things like disabling NTP and using usleep but it always skips and causes my program to flip out for a second. What is this sorcery? Thanx

In reply to missing second of time by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.