use Benchmark; use Data::Dumper qw(Dumper DumperX); use Storable qw(freeze nfreeze thaw); use MIME::Base64; use XML::Dumper; use XML::Parser; my $object = { # some complex data structure here }; timethese(5000,{ 'Dumper' => sub { my $string = Dumper($object); my $obj = eval($string); }, 'DumperX' => sub { my $string = DumperX($object); my $obj = eval($string); }, 'freeze' => sub { my $string = freeze($object); my $obj = thaw($string); }, 'nfreeze' => sub { my $string = nfreeze($object); my $obj = thaw($string); }, 'base64nfreeze' => sub { my $string = encode_base64(nfreeze($object)); my $obj = thaw(decode_base64($string)); }, 'xmlDumper' => sub { my $string = XML::Dumper->pl2xml($object); my $tree = $xmlParser->parse($string); my $obj = XML::Dumper->xml2pl($tree); }, });