Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This is very nice. I thought I'd add a few tips of my own:
  • Caching is the enemy of benchmarking. Make sure that the code you're benchmarking doesn't do any caching of the results. This is particularly important if you're using code that other people have written (e.g., modules from CPAN) as part of the code that you're benchmarking.
  • Benchmarked code uses package global variables. This is extremely important to note, because if you use lexicals, your benchmark results will mean nothing, because you'll most likely be using undefined values, or values that you're not trying to test. So this goes along with turnstep's recommendation to make sure that your code works before you benchmark it: make sure that it works *while* you're benchmarking it. Most of the time, I use a loop count of 1 the first time I run a benchmark, then I print out the values within the code reference (or string) to make sure I've got everything right.
  • Don't intermix eval'd strings with code references, because, according to the Benchmark manpage, code references will show slower execution times than the equivalent eval'd strings.

In reply to RE: Benchmarking Your Code by btrott
in thread Benchmarking Your Code by turnstep

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found