Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^5: Initializing iterations while benchmarking

by alexm (Chaplain)
on Aug 07, 2009 at 11:05 UTC ( #786749=note: print w/replies, xml ) Need Help??

in reply to Re^4: Initializing iterations while benchmarking
in thread Initializing iterations while benchmarking

As setting pos takes time that will not be required in the real code, it introduces an error in the benchmark results.

But pos is actually needed in real code in this case, as proven in strange behavior of grep with global match [resolved], isn't it?

Then we are back to the possibility that time to initialize obscures the differences in the code under test.

It seems that Benchmark isn't fit for the job, you may need a profiler to mark where you want to start and end mesuring. I have little experience in profilers, so I can't suggest anything at the moment.

  • Comment on Re^5: Initializing iterations while benchmarking

Replies are listed 'Best First'.
Re^6: Initializing iterations while benchmarking
by ig (Vicar) on Aug 07, 2009 at 11:19 UTC

    In the case I was looking at, each string would be tested only once, so no need to set pos before the test. It only became an issue when the same test was performed on the same string as the benchmark test iterated.

    The broader issue of excluding setup time from the benchmark results is what interests me here. This example is merely what I was looking at when I began to consider the issue. It is a concrete example but otherwise not important in itself.

    Thanks for sharing your thoughts.

    update: revised/clarified (I hope) the first paragraph.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://786749]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2018-06-23 16:48 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.