--- JSON-XS/eg/bench 2007/04/03 23:59:04 1.8 +++ JSON-XS/eg/bench 2007/04/10 03:47:26 1.9 @@ -7,6 +7,7 @@ use JSON::PC; use JSON::XS qw(to_json from_json); use JSON::Syck; +use Storable (); use Time::HiRes; use List::Util; @@ -23,6 +24,9 @@ local $/; $json = <>; +# fix syck-brokenised stuff +$json = JSON::XS->new->ascii(1)->encode (JSON::Syck::Load $json); + #srand 0; $json = JSON::XS->new->utf8(1)->ascii(0)->encode ([join "", map +(chr rand 255), 0..2047]); #if (1) { @@ -43,13 +47,16 @@ "JSON::XS" => ['to_json $perl' , 'from_json $json'], "JSON::XS/2" => ['$xs2->encode ($perl)' , '$xs2->decode ($json)'], "JSON::XS/3" => ['$xs3->encode ($perl)' , '$xs3->decode ($json)'], + "Storable" => ['Storable::nfreeze $perl', 'Storable::thaw $pst'], ); sub bench($) { my ($code) = @_; my $perl = jsonToObj $json; - my $count = 20; + my $pst = Storable::nfreeze $perl; + + my $count = 2; my $times = 25; my $cent = eval "sub { " . (join ";", ($code) x $count) . "}";