Never one to wait for an answer, I kept digging and finally decided to pull out the trusty Benchmark module:

#!/usr/bin/perl -w use strict; use Benchmark; my %hash = ( DefaultLimit => 900, TimeLimit => 900, MODE => 'Off' ); sub by_hash { my $time_to_die; if ($hash{'TimeLimit'}) { if ($hash{'TimeLimit'} < $hash{'DefaultLimit'}) { $time_to_die = $hash{'TimeLimit'}; } else { $time_to_die = $hash{'DefaultLimit'}; } } else { $time_to_die = $hash{'DefaultLimit'}; } } sub by_var { my ($default, $time_to_die, $limit); $default = $hash{'DefaultLimit'}; $limit = $hash{'TimeLimit'} if ($hash{'TimeLimit'}); ($limit && ($limit < $default)) ? $time_to_die = $limit : $tim +e_to_die = $default; } timethese (100000, { hash => 'by_hash', var => 'by_var'});

Yeilds this:

[13:20:12 jhorner@gateway lib]$ ./test1.pl Benchmark: timing 100000 iterations of hash, var... hash: 5 wallclock secs ( 4.57 usr + 0.00 sys = 4.57 CPU) @ 21 +881.84/s (n=100000) var: 4 wallclock secs ( 3.74 usr + 0.00 sys = 3.74 CPU) @ 26 +737.97/s (n=100000) [13:20:24 jhorner@gateway lib]$

This leads me to believe that I should use temp variables to store this data. Anyone have any comments, or suggestions?

Has anyone else reached any other results?

Thanks,

J. J. Horner
Linux, Perl, Apache, Stronghold, Unix
jhorner@knoxlug.org http://www.knoxlug.org/

In reply to RE: $r-dir_config and speed by jjhorner
in thread $r-dir_config and speed by jjhorner

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.