Nope. Looking at the code in HiRes.xs, I see nothing that would be caching it. On the contrary, the fact that the gettimeofday() maps directly to the system api on your system means that the path from Perl to XS to OS and back is almost a straight one:

void gettimeofday() PREINIT: struct timeval Tp; PPCODE: int status; status = gettimeofday (&Tp, NULL); if (status == 0) { if (GIMME == G_ARRAY) { EXTEND(sp, 2); PUSHs(sv_2mortal(newSViv(Tp.tv_sec))); PUSHs(sv_2mortal(newSViv(Tp.tv_usec))); } else { EXTEND(sp, 1); PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / 10 +00000.0)))); } }

That combined with your using 5.6.2, which doesn't need to lookup thread contexts, means that the overhead of the transitions is truely minimal.

I have to sit corrected and chalk one up to linux here. Using Perl on a system which forms the core of it's built-ins architecture has distinct performance advantages.

What triggered the caching thing in my mind was your making both calls to gettimeofday() within the same statement. I have a built in suspicion of this that I realise now is a hangover from using some time-related calls in C. On at least two C compilers I've used in the past, the compiler would do a subexpression elimination on a pair of identical calls in the same statement with the result that you the same value both times. I was bitten by this in a rather expensive way once.

That is obviously not the case here, but old pain lives long in the memory.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: OT How fast a cpu to overwhelm Time::HiRes by BrowserUk
in thread OT How fast a cpu to overwhelm Time::HiRes by zentara

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.