Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^15: "Automated" benchmarking

by BrowserUk (Pope)
on Jan 25, 2012 at 20:12 UTC ( #949953=note: print w/ replies, xml ) Need Help??


in reply to Re^14: "Automated" benchmarking
in thread "Automated" benchmarking

I wasn't doubting you. Just still puzzling how a subroutine that is called 5000 times can result in 5003 sentences?

In the other cases, it is fairly easy to see how xxx() for ... ; could result in double the number of sentence as there are lines.

But those odd 3 are just beyond my ability to reason.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


Comment on Re^15: "Automated" benchmarking
Download Code
Re^16: "Automated" benchmarking
by salva (Monsignor) on Jan 26, 2012 at 09:04 UTC
    With perl 5.8.9 on Linux, replacing the calls to Win32::Sleep by calls to Time::HiRes::nanosleep, I get the expected count of 5000.

    Probably, that 3 extra sentences are from some callback run from Win32::Sleep the first time it is called. Maybe you could use Devel::Trace or single step through the debugger to see what's going on.

      Thanks. That clears things up. (Well mostly:).

      The answer appears to be something to do with the fact that Win32::Sleep() is a built-in masquerading as an autoloaded module "export".

      That is to say, you don't have to do use Win32; prior to using Win32::Sleep().

      However, if you do use Win32;, then do the profiling, you get just:

      ================ SmallProf version 2.02 ================ Profile of test-p.pl + Page 1 =============================================================== +== count wall tm cpu time line 0 0.00000 0.00000 1:#! perl -slw 0 0.00000 0.00000 2:use strict; 0 0.00000 0.00000 3:use Win32; 0 0.00000 0.00000 4: 0 0.00000 0.00000 5:sub aaa { 5000 4.93252 0.00000 6: Win32::Sleep( 1 ); 0 0.00000 0.00000 7:} 0 0.00000 0.00000 8: 0 0.00000 0.00000 9:sub bbb { 500 4.99202 0.00000 10: Win32::Sleep( 10 ); 0 0.00000 0.00000 11:} 0 0.00000 0.00000 12: 0 0.00000 0.00000 13:sub ccc { 50 4.99873 0.00000 14: Win32::Sleep( 100 ); 0 0.00000 0.00000 15:} 0 0.00000 0.00000 16: 0 0.00000 0.00000 17:sub ddd { 5 4.99969 0.00000 18: Win32::Sleep( 1000 ); 0 0.00000 0.00000 19:} 0 0.00000 0.00000 20: 0 0.00000 0.00000 21:sub eee { 10 0.00008 0.00000 22: aaa() for 1 .. 1000; 10 0.00008 0.00000 23: bbb() for 1 .. 100; 10 0.00008 0.00000 24: ccc() for 1 .. 10; 10 0.00008 0.00000 25: ddd() for 1 .. 1; 0 0.00000 0.00000 26:} 0 0.00000 0.00000 27: 2 0.00001 0.00000 28:eee() for 1 .. 5; 0 0.00000 0.00000 29:

      I do mean "just". Without the use, it profiles all of the usual things strict; warnings; Dynaloader; Autoloader; Config; Carp; Cwd; etc. etc.

      But by adding use Win32;, all of that profile trace vanishes, and you get just the above output. Which is cool in a weird sort of way (or weird in a cool sort of way:), but has the bonus that now the counts are as expected.

      Not totally satisfactory as an explanation in as much as it opens another bunch of questions -- like: why does strict.pm et al no longer get traced? (Regardless of whether the use strict; comes before or after the use Win32; --, but it is enough to satiate my curiosity.

      As an added bonus, I shall be adding use Win32; to more of my scripts -- at least when profiling, because it stops the profilers profiling all the modules I'm (usually) not interested in seeing. Which both speeds up the profiling and reduces the volume of the output.

      Curiosity has its upsides sometimes :) Thanks for all your help.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://949953]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-09-24 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (244 votes), past polls