--- JSON-XS/eg/bench 2007/03/22 21:13:58 1.1 +++ JSON-XS/eg/bench 2007/03/24 22:55:16 1.6 @@ -15,13 +15,16 @@ my $dwiw = new JSON::DWIW; my $pc = new JSON::PC; -my $xs = JSON::XS->new->pretty (1)->canonical (1); +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 255), 0..2047]); + #if (1) { # use Storable; # open my $fh, "<:unix", "/opt/crossfire/share/cfserver/faces" or die "$!"; @@ -33,20 +36,21 @@ #} my %tst = ( + "JSON" => ['objToJson $perl' , 'jsonToObj $json'], "JSON::DWIW" => ['$dwiw->to_json ($perl)', '$dwiw->from_json ($json)'], - "JSON::Syck" => ['JSON::Syck::Dump $perl', 'JSON::Syck::Load $json'], "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], - "JSON" => ['objToJson $perl' , 'jsonToObj $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($) { my ($code) = @_; my $perl = jsonToObj $json; - my $count = 100; - my $times = 15; + my $count = 20; + my $times = 25; my $cent = eval "sub { " . (join ";", ($code) x $count) . "}"; $cent->();