in reply to Re: Unique numeric ID for reference?
in thread Unique numeric ID for reference?
Benchmark: running ID Field, Numeric, Refaddr, String for at least 3 C +PU seconds... ID Field: 4 wallclock secs ( 3.43 usr + 0.03 sys = 3.46 CPU) @ 10 +44124.57/s (n=3612671) Numeric: 4 wallclock secs ( 3.34 usr + 0.04 sys = 3.38 CPU) @ 98 +9664.50/s (n=3345066) Refaddr: 5 wallclock secs ( 3.08 usr + 0.03 sys = 3.11 CPU) @ 91 +2330.23/s (n=2837347) String: 4 wallclock secs ( 3.09 usr + 0.04 sys = 3.13 CPU) @ 74 +7332.27/s (n=2339150)
And here's the code that did the Benchmark:Rate String Refaddr Numeric ID Field String 747332/s -- -18% -24% -28% Refaddr 912330/s 22% -- -8% -13% Numeric 989664/s 32% 8% -- -5% ID Field 1044125/s 40% 14% 6% --
#!perl -w use strict; use Benchmark qw(:all); use Scalar::Util qw(refaddr); my $r = [0]; sub string { pack("A", "$r"); } sub numeric { pack("J", $r+0); } sub addr { pack("J", refaddr $r); } sub field { pack("J", $r->[0]); } my $result = timethese(-3, { String => \&string, Numeric => \&numeric, Refaddr => \&addr, "ID Field" => \&field, }); cmpthese($result);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A benchmark
by Juerd (Abbot) on Oct 07, 2007 at 14:05 UTC | |
by Jeffrey Kegler (Hermit) on Oct 07, 2007 at 15:07 UTC | |
by Juerd (Abbot) on Oct 08, 2007 at 12:49 UTC |