File: deserialize.pl

package info (click to toggle)
libdata-messagepack-perl 1.02-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,060 kB
  • sloc: ansic: 5,697; perl: 1,123; makefile: 10
file content (27 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (7)
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
use strict;
use warnings;
use Data::MessagePack;
use JSON;
use Storable;
use Benchmark ':all';

#$Data::MessagePack::PreferInteger = 1;

my $a = do 'benchmark/data.pl';

my $j = JSON::encode_json($a);
my $m = Data::MessagePack->pack($a);
my $s = Storable::freeze($a);

print "-- deserialize\n";
print "$JSON::Backend: ", $JSON::Backend->VERSION, "\n";
print "Data::MessagePack: $Data::MessagePack::VERSION\n";
print "Storable: $Storable::VERSION\n";
cmpthese timethese(
    -1 => {
        json     => sub { JSON::decode_json($j)     },
        mp       => sub { Data::MessagePack->unpack($m) },
        storable => sub { Storable::thaw($s) },
    }
);