in reply to Re^2: Dump, Dup or Copy an object
in thread Dump, Dup or Copy an object

Out of curiosity i benchmarked it and got the following results:
use Benchmark qw(timethese); use Clone; use Storable; #use Scalar::Util::Clone; my $struct = { 'foo' => 'bar', 'move' => 'zig', bar => [1, 2, 3] }; timethese ( 500000, { 'Clone' => sub { my $s = Clone::clone($struct) + }, #'Scalar::Util::Clone' => sub { my $s = Scalar::Util::Clone::c +lone ($struct) }, 'Storable' => sub { my $s = Storable::dclone ($stru +ct) } } ); #Benchmark: timing 500000 iterations of Clone, Storable... # Clone: 3 wallclock secs ( 4.28 usr + 0.00 sys = 4.28 CPU) @ 1169 +04.37/s (n=500000) # Storable: 74 wallclock secs (69.62 usr + 0.03 sys = 69.65 CPU) @ 7 +178.65/s (n=500000)
The reason because Scalar::Util::Clone is commented out is that I couldn't make it compile nor did I find a ppd for it. Maybe someone else can step in?


holli, /regexed monk/

Replies are listed 'Best First'.
Re^4: Dump, Dup or Copy an object
by turo (Friar) on Feb 22, 2006 at 16:09 UTC

    on my machine, these are the results of the benchmarking:

    Benchmark: timing 500000 iterations of Clone, Storable... Clone: 4 wallclock secs ( 3.27 usr + 0.00 sys = 3.27 CPU) @ 15 +2905.20/s (n=500000) Storable: 30 wallclock secs (29.52 usr + 0.01 sys = 29.53 CPU) @ 16 +931.93/s (n=500000)
    (... is a Pentium 4, 3GHz (cache 2MB) and 1GB of RAM) ...

    Seems that Storable is a little bit slowler than Clone. But, on the other hand, i didn't have to install it ... seems to be at the main perl distrib ...

    perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'