develooper Front page | perl.perl5.porters | Postings from May 2012

vec v. ord

Thread Next
May 10, 2012 12:33
vec v. ord
Message ID:
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)},
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.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About