--- JSON-XS/eg/bench 2007/03/24 22:10:09 1.5 +++ JSON-XS/eg/bench 2007/04/03 23:59:04 1.8 @@ -5,7 +5,7 @@ use JSON; use JSON::DWIW; use JSON::PC; -use JSON::XS; +use JSON::XS qw(to_json from_json); use JSON::Syck; use Time::HiRes; @@ -15,14 +15,15 @@ my $dwiw = new JSON::DWIW; my $pc = new JSON::PC; -my $xs = JSON::XS->new->pretty->canonical->shrink; +my $xs2 = JSON::XS->new->utf8->pretty->canonical; +my $xs3 = JSON::XS->new->utf8->shrink; my $json; # the test string local $/; $json = <>; -srand 0; $json = JSON::XS->new->utf8(1)->ascii(0)->encode ([join "", map +(chr rand 2555), 0..2047]); +#srand 0; $json = JSON::XS->new->utf8(1)->ascii(0)->encode ([join "", map +(chr rand 255), 0..2047]); #if (1) { # use Storable; @@ -36,11 +37,12 @@ my %tst = ( # "JSON" => ['objToJson $perl' , 'jsonToObj $json'], -# "JSON::DWIW" => ['$dwiw->to_json ($perl)', '$dwiw->from_json ($json)'], -# "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], -# "JSON::Syck" => ['JSON::Syck::Dump $perl', 'JSON::Syck::Load $json'], + "JSON::DWIW" => ['$dwiw->to_json ($perl)', '$dwiw->from_json ($json)'], + "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], + "JSON::Syck" => ['JSON::Syck::Dump $perl', 'JSON::Syck::Load $json'], "JSON::XS" => ['to_json $perl' , 'from_json $json'], - "JSON::XS/2" => ['$xs->encode ($perl)' , '$xs->decode ($json)'], + "JSON::XS/2" => ['$xs2->encode ($perl)' , '$xs2->decode ($json)'], + "JSON::XS/3" => ['$xs3->encode ($perl)' , '$xs3->decode ($json)'], ); sub bench($) {