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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |