mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 13:02:13 +01:00
Improve benchmarks
This commit is contained in:
parent
0768cf17b6
commit
0f02ef20a9
@ -9,7 +9,7 @@ my $a = {
|
|||||||
"method" => "handleMessage",
|
"method" => "handleMessage",
|
||||||
"params" => [ "user1", "we were just talking" ],
|
"params" => [ "user1", "we were just talking" ],
|
||||||
"id" => undef,
|
"id" => undef,
|
||||||
"array" => [ 1, 11, 234, -5, 1e5, 1e7, 1, 0 ]
|
"array" => [ 1, 11, 234, -5, 1e5, 1e7, 1, 0, 3.14, sqrt(2) ]
|
||||||
};
|
};
|
||||||
my $j = JSON::XS::encode_json($a);
|
my $j = JSON::XS::encode_json($a);
|
||||||
my $m = Data::MessagePack->pack($a);
|
my $m = Data::MessagePack->pack($a);
|
||||||
@ -19,8 +19,8 @@ print "-- deserialize\n";
|
|||||||
print "JSON::XS: $JSON::XS::VERSION\n";
|
print "JSON::XS: $JSON::XS::VERSION\n";
|
||||||
print "Data::MessagePack: $Data::MessagePack::VERSION\n";
|
print "Data::MessagePack: $Data::MessagePack::VERSION\n";
|
||||||
print "Storable: $Storable::VERSION\n";
|
print "Storable: $Storable::VERSION\n";
|
||||||
timethese(
|
cmpthese timethese(
|
||||||
1000000 => {
|
-1 => {
|
||||||
json => sub { JSON::XS::decode_json($j) },
|
json => sub { JSON::XS::decode_json($j) },
|
||||||
mp => sub { Data::MessagePack->unpack($m) },
|
mp => sub { Data::MessagePack->unpack($m) },
|
||||||
storable => sub { Storable::thaw($s) },
|
storable => sub { Storable::thaw($s) },
|
||||||
|
@ -9,15 +9,15 @@ my $a = {
|
|||||||
"method" => "handleMessage",
|
"method" => "handleMessage",
|
||||||
"params" => [ "user1", "we were just talking" ],
|
"params" => [ "user1", "we were just talking" ],
|
||||||
"id" => undef,
|
"id" => undef,
|
||||||
"array" => [ 1, 11, 234, -5, 1e5, 1e7, 1, 0 ]
|
"array" => [ 1, 11, 234, -5, 1e5, 1e7, 1, 0, 3.14, sqrt(2) ]
|
||||||
};
|
};
|
||||||
|
|
||||||
print "-- serialize\n";
|
print "-- serialize\n";
|
||||||
print "JSON::XS: $JSON::XS::VERSION\n";
|
print "JSON::XS: $JSON::XS::VERSION\n";
|
||||||
print "Data::MessagePack: $Data::MessagePack::VERSION\n";
|
print "Data::MessagePack: $Data::MessagePack::VERSION\n";
|
||||||
print "Storable: $Storable::VERSION\n";
|
print "Storable: $Storable::VERSION\n";
|
||||||
timethese(
|
cmpthese timethese(
|
||||||
1000000 => {
|
-1 => {
|
||||||
json => sub { JSON::XS::encode_json($a) },
|
json => sub { JSON::XS::encode_json($a) },
|
||||||
storable => sub { Storable::freeze($a) },
|
storable => sub { Storable::freeze($a) },
|
||||||
mp => sub { Data::MessagePack->pack($a) },
|
mp => sub { Data::MessagePack->pack($a) },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user