http://www.perlmonks.org?node_id=949928


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

Could this be a benefit of using a multicore system?

Yes, that may be or that I have hyper threading activated on my desktop machine.

For the last line eee() for 1 .. 5;, the count is two but ought be one

You get that numbers because both Devel::SmallProf and Devel::NYTProf are not counting lines but "sentences" executed

It also seems that the meaning of "sentence" changes between perl versions. Under 5.8, I get similar results to the ones you have posted. Under 5.14, I get different ones:

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 Time::HiRes qw[ time ]; 0 0.00000 0.00000 4: 0 0.00000 0.00000 5:sub aaa { 5000 5.83176 0.17000 6: Time::HiRes::nanosleep( 1_000_ +000 ); 0 0.00000 0.00000 7:} 0 0.00000 0.00000 8: 0 0.00000 0.00000 9:sub bbb { 500 5.27816 0.00000 10: Time::HiRes::nanosleep( 10_000 +_000 ); 0 0.00000 0.00000 11:} 0 0.00000 0.00000 12: 0 0.00000 0.00000 13:sub ccc { 50 5.01925 0.00000 14: Time::HiRes::nanosleep( 100_00 +0_000 ); 0 0.00000 0.00000 15:} 0 0.00000 0.00000 16: 0 0.00000 0.00000 17:sub ddd { 5 5.00106 0.00000 18: Time::HiRes::nanosleep( 1_000_ +000_000 ); 0 0.00000 0.00000 19:} 0 0.00000 0.00000 20: 0 0.00000 0.00000 21:sub eee { 0 0.00000 0.00000 22: aaa() 5 0.00001 0.00000 23: for 1 .. 1000; 0 0.00000 0.00000 24: bbb() 5 0.00001 0.00000 25: for 1 .. 100; 0 0.00000 0.00000 26: ccc() 5 0.00001 0.00000 27: for 1 .. 10; 0 0.00000 0.00000 28: ddd() 5 0.00001 0.00000 29: for 1 .. 1; 0 0.00000 0.00000 30:} 0 0.00000 0.00000 31: 1 0.00001 0.00000 32:eee for 1..5;

Replies are listed 'Best First'.
Re^13: "Automated" benchmarking
by BrowserUk (Patriarch) on Jan 25, 2012 at 17:04 UTC
    both Devel::SmallProf and Devel::NYTProf are not counting lines but "sentences" executed

    Okay. I guess have to take that as read.

    I'm still intrigued by the extra 3 'sentences' for the sleep in aaa() though?


    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?

      From perldebguts:

      When the execution of your program reaches a point that can hold a breakpoint, the "DB::DB()" subroutine is called if any of the variables $DB::trace, $DB::single, or $DB::signal is true.

      And that's what Devel::SmallProf and Devel::NYTProf are counting, calls to DB::DB().

        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?