Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^17: "Automated" benchmarking

by BrowserUk (Patriarch)
on Jan 26, 2012 at 10:04 UTC ( [id://950064]=note: print w/replies, xml ) Need Help??


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

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://950064]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 19:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found