--- JSON-XS/eg/bench 2008/03/19 04:08:22 1.18 +++ JSON-XS/eg/bench 2008/03/25 06:37:39 1.20 @@ -2,12 +2,12 @@ # Usage: bench json-file -# which modules to test (JSON usually excluded because its so slow) +# which modules to test (JSON::PP usually excluded because its so slow) my %tst = ( -# "JSON" => ['JSON::objToJson $perl' , 'JSON::jsonToObj $json'], +# "JSON" => ['JSON::encode_json $perl' , 'JSON::decode_json $json'], # "JSON::PP" => ['$pp->encode ($perl)' , '$pp->decode ($json)'], "JSON::DWIW" => ['$dwiw->to_json ($perl)' , '$dwiw->from_json ($json)'], -# "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], + "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], "JSON::Syck" => ['JSON::Syck::Dump $perl' , 'JSON::Syck::Load $json'], "JSON::XS" => ['encode_json $perl' , 'decode_json $json'], "JSON::XS/2" => ['$xs2->encode ($perl)' , '$xs2->decode ($json)'], @@ -57,11 +57,11 @@ sub bench($) { my ($code) = @_; + my $pst = Storable::nfreeze JSON::XS::decode_json $json; # seperately decode as storable stringifies :/ my $perl = JSON::XS::decode_json $json; - my $pst = Storable::nfreeze $perl; my $count = 5; - my $times = 200; + my $times = 2; my $cent = eval "sub { my \$t = Time::HiRes::time; " . (join ";", ($code) x $count) . "; Time::HiRes::time - \$t }"; $cent->();