Since tye didn't say anything about it in his post, I'd like to point out that you might wish to look at his use of Benchmark. Honestly, if you are going to do 100000 of something or so, Time::HiRes doesn't buy you much in accuracy.

If you are going to start timing stuff on a regular basis use Benchmark and enjoy the benefits of others hard labor. Since I love these sorts of comparisons, I keep a "testit" file around that looks like this:

#!/usr/bin/perl -w use strict; use Benchmark qw(cmpthese); #cmpthese gives a nice comparison table use vars qw($s @a $h); # I so that data is visible in evals/subs for s +ure # $s = shift; # test scalar (ARGV) # @a = <DATA>; # test array # %h = map { split/=>/ } <DATA> # test hash cmpthese ( -10, #ten seconds rather than X number of loops { 'one' => '', # eval string style 'two' => sub {}, # sub ref style }); __DATA__

With the above I can cut-n-paste in code from various places and give it a whirl in no-time. I do recommend that you stick with all sub references or all evals tho, just to keep your sanity.

--
$you = new YOU;
honk() if $you->love(perl)


In reply to Re: Why is split faster than anonymous arrays? by extremely
in thread Why is split faster than anonymous arrays? by rrwo

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.