Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Question about benchmarking

by Anonymous Monk
on Aug 17, 2001 at 00:38 UTC ( [id://105586]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Question about benchmarking
in thread Question about benchmarking

Answer to number 3: run (under windows)
perldoc Benchmark
to read the POD for the module. If you have a somewhat old and/or broken install (like me), you can always fall back to
vi \perl\lib\Benchmark.pm
:)

What you've written is a proper way of using benchmark. Ideally, you would insert several objects into your code to get the times you wanted, but you can do it in a clever and inobtrusive manner:

BEGIN { use Benchmark; my ($oldb, $newb); # inside BEGIN for closure sub mybench { return unless ($opt_b); $newb = new Benchmark; if ($oldb) { # i.e. don't run first time through print timediff($oldb, $newb); } $oldb = $newb; } } Getopt::Std; getopts('b'); mybench(); # some code here mybench(); # some more code here mybench();
and then it would be trivial to remove the benchmarking from your production code, either through a command line switch, as above:
mycode.pl -b
or some line in your makefile like:
perl -lne 'print unless /^\s*mybench();/' myscript.pl > production.pl
ya know.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://105586]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.