ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/eg/bench
(Generate patch)

Comparing JSON-XS/eg/bench (file contents):
Revision 1.19 by root, Wed Mar 19 15:17:54 2008 UTC vs.
Revision 1.20 by root, Tue Mar 25 06:37:39 2008 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# Usage: bench json-file 3# Usage: bench json-file
4 4
5# which modules to test (JSON usually excluded because its so slow) 5# which modules to test (JSON::PP usually excluded because its so slow)
6my %tst = ( 6my %tst = (
7 "JSON" => ['JSON::encode_json $perl' , 'JSON::decode_json $json'], 7# "JSON" => ['JSON::encode_json $perl' , 'JSON::decode_json $json'],
8 "JSON::PP" => ['$pp->encode ($perl)' , '$pp->decode ($json)'], 8# "JSON::PP" => ['$pp->encode ($perl)' , '$pp->decode ($json)'],
9 "JSON::DWIW" => ['$dwiw->to_json ($perl)' , '$dwiw->from_json ($json)'], 9 "JSON::DWIW" => ['$dwiw->to_json ($perl)' , '$dwiw->from_json ($json)'],
10 "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], 10 "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'],
11 "JSON::Syck" => ['JSON::Syck::Dump $perl' , 'JSON::Syck::Load $json'], 11 "JSON::Syck" => ['JSON::Syck::Dump $perl' , 'JSON::Syck::Load $json'],
12 "JSON::XS" => ['encode_json $perl' , 'decode_json $json'], 12 "JSON::XS" => ['encode_json $perl' , 'decode_json $json'],
13 "JSON::XS/2" => ['$xs2->encode ($perl)' , '$xs2->decode ($json)'], 13 "JSON::XS/2" => ['$xs2->encode ($perl)' , '$xs2->decode ($json)'],
59 59
60 my $pst = Storable::nfreeze JSON::XS::decode_json $json; # seperately decode as storable stringifies :/ 60 my $pst = Storable::nfreeze JSON::XS::decode_json $json; # seperately decode as storable stringifies :/
61 my $perl = JSON::XS::decode_json $json; 61 my $perl = JSON::XS::decode_json $json;
62 62
63 my $count = 5; 63 my $count = 5;
64 my $times = 200; 64 my $times = 2;
65 65
66 my $cent = eval "sub { my \$t = Time::HiRes::time; " . (join ";", ($code) x $count) . "; Time::HiRes::time - \$t }"; 66 my $cent = eval "sub { my \$t = Time::HiRes::time; " . (join ";", ($code) x $count) . "; Time::HiRes::time - \$t }";
67 $cent->(); 67 $cent->();
68 68
69 my $min = 1e99; 69 my $min = 1e99;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines