1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!perl -w
use strict;
use Benchmark qw(:all);
use Storable ();
use Clone ();
use Data::Clone ();
BEGIN{
package Object;
sub new {
my $class = shift;
return bless { @_ }, $class;
}
package ST;
use Storable ();
our @ISA = qw(Object);
*clone = \&Storable::dclone;
package C;
use Clone qw(clone);
our @ISA = qw(Object);
package DC;
use Data::Clone qw(clone);
our @ISA = qw(Object);
}
my %args = (
foo => 42,
inc => { %INC },
);
my $st = ST->new(%args);
my $c = C->new(%args);
my $dc = DC->new(%args);
print "Object:\n";
cmpthese -1 => {
'Clone' => sub{
my $x = $c->clone;
},
'Storable' => sub{
my $x = $st->clone;
},
'Data::Clone' => sub{
my $x = $dc->clone;
},
};
|