perrin has asked for the wisdom of the Perl Monks concerning the following question:

Silly question, but the code for Benchmark is a little obtuse and the docs don't seem clear on this point:

Is the rate calculation done by Benchmark::cmpthese() mesured in wallclock time, or in CPU time? I want wallclock time, because I'm measuring things that are I/O intensive.

Replies are listed 'Best First'.
Re: Benchmark and wallclock times
by mulander (Monk) on Sep 20, 2005 at 05:41 UTC
    Imho the Benchmark subrutines all give back time in wallocsecs, if cmpthese(); works diffrently you can always wrap it inside timethese(); or another sub that returns time in wallocsec.

    This is what perldoc Benchmark tells you about a possible modification of wallocsecs:
    :hireswallclock If the Time::HiRes module has been installed, you can specify the special tag ":hireswallclock" for Benchmark (if Time::HiRes is not available, the tag will be silently ignored). This tag will cause t +he wallclock time to be measured in microseconds, instead of integer seconds. Note though that the speed computations are still conducte +d in CPU time, not wallclock time.
Re: Benchmark and wallclock times
by Anonymous Monk on Sep 20, 2005 at 13:22 UTC
    Despite what the previous poster says, Benchmark::cmpthese uses CPU time to create the chart with ratios. By default, Benchmark::timethese shows a breakdown in times (wallclock, system, user, child-system and child-user), but doesn't give you a ratio chart. The iterations/second given by timethese will use CPU seconds. You have some control of which times will be shown by using a third parameter to timethese.

    Do mind Benchmark wasn't written with wallclock seconds in mind (and in fact, it wasn't written for the purpose of measuring I/O). You're probably better off using some other tool.