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

map {thanks} qw(arkturuz borisz holli);

The Storable module is what i need (i think so, after reading the pod):

# Deep (recursive) cloning $cloneref = dclone($ref);


ummm, The Class::Cloneable, is cool, but remembers me c++ and the copy constructor, maybe i'll consider to use it soon ... :-) .
And, at last the powerfull Data::Dumper is too complex, i suppose, for what i wantted to do (indeed, i don't know what to do with it ^_^> ... by the momment), ...

Cheers

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

Replies are listed 'Best First'.
Re^3: Dump, Dup or Copy an object
by holli (Abbot) on Feb 22, 2006 at 15:30 UTC
    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/

      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"'