Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Getting timing details from a test

by kennethk (Abbot)
on Jan 07, 2011 at 20:42 UTC ( [id://881162]=note: print w/replies, xml ) Need Help??


in reply to Getting timing details from a test

If your goal is benchmarking or profiling, you should probably use software developed for that purpose. The usual go-tos there are Benchmark and Devel::NYTProf, respectively.

If you really want to including timing in your test result statements, you could use Time::HiRes to add appropriate output to your test descriptions.

Replies are listed 'Best First'.
Re^2: Getting timing details from a test
by mcdave (Beadle) on Jan 13, 2011 at 18:11 UTC
    Thanks for mentioning "Benchmark". It turned out to be really easy to splice in. Just put some "new Benchmark" statements between my existing tests, and I'm good:
    ... use Benchmark qw(:hireswallclock); use Test::More ; ... $t0 = Benchmark->new ; ok(&test1, 'the first test') ; $t1 = Benchmark->new ; ok(&test2, 'test #2' ) ; $t2 = Benchmark->new ; ok(&test3, 'done now' ) ; $t3 = Benchmark->new ; note( 'the first test: ' . timestr(timediff($t1, $t0) ) ) ; note( 'test #2: ' . timestr(timediff($t2, $t1) ) ) ; note( 'done now: ' . timestr(timediff($t3, $t2) ) ) ;
    That's giving output I can work with.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-20 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found