Generally speaking the GRT is a signifigant improvement on the ST
But it doesn't seem te be an improvement with your example sort:
Benchmark: running bare, grt, st for at least 3 CPU seconds...
bare: 6 wallclock secs ( 3.08 usr + 0.01 sys = 3.09 CPU) @ 12
+79584.47/s (n=3953916)
grt: 8 wallclock secs ( 3.11 usr + 0.00 sys = 3.11 CPU) @ 11
+18145.66/s (n=3477433)
st: 7 wallclock secs ( 3.05 usr + 0.01 sys = 3.06 CPU) @ 11
+46781.05/s (n=3509150)
Rate grt st bare
grt 1118146/s -- -2% -13%
st 1146781/s 3% -- -10%
bare 1279584/s 14% 12% --
#!/usr/bin/perl -w
use strict;
use Benchmark qw(cmpthese);
my @words = qw(The time has come the Walrus said to speak of many thin
+gs);
cmpthese(-3, {
st => q{
my @sorted =
map { $_->[1] }
sort { $a->[0] <=> $a->[0] || $a->[1] cmp $b->[1] }
map { [ tr/eE/eE/, $_ ] } @words;
},
grt => q{
my @sorted =
map { substr($_, 4) }
sort
map { pack("LA*", tr/eE/eE/, $_) } @words;
},
bare => q{
my @sorted = sort { ($a =~ tr/eE/eE/) <=> ($b =~ tr/eE/eE/) }
+@words;
}
});
This is perl, v5.8.0 built for i686-linux
Juerd
# { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|