Front page | perl.perl5.porters |
Postings from May 2012
vec v. ord
Thread Next
From:
hv
Date:
May 10, 2012 12:33
Subject:
vec v. ord
Message ID:
201205101905.q4AJ5Iu19207@crypt.org
Hmm, is this just showing it takes longer to stack 3 arguments than 1,
or does it show room for some optimizations in vec()?
% bleadperl -MBenchmark=cmpthese -wl
$s = "test";
cmpthese(-1, {
"ord" => q{$t=ord($s)},
"vec" => q{$t=vec($s, 0, 8)},
})
__END__
Name "main::s" used only once: possible typo at -e line 1.
Rate vec ord
vec 3044813/s -- -40%
ord 5041230/s 66% --
%
(Timings are very unreliable on this machine, but the numbers above
are close to the median I saw.)
It seems to me ord() needs to do extra work (eg to consider utf8), so
vec() ought to be the faster.
Hugo
Thread Next