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.5 by root, Sat Mar 24 22:10:09 2007 UTC vs.
Revision 1.6 by root, Sat Mar 24 22:55:16 2007 UTC

13 13
14use utf8; 14use utf8;
15 15
16my $dwiw = new JSON::DWIW; 16my $dwiw = new JSON::DWIW;
17my $pc = new JSON::PC; 17my $pc = new JSON::PC;
18my $xs = JSON::XS->new->pretty->canonical->shrink; 18my $xs2 = JSON::XS->new->utf8->pretty->canonical;
19my $xs3 = JSON::XS->new->utf8->shrink;
19 20
20my $json; # the test string 21my $json; # the test string
21 22
22local $/; 23local $/;
23$json = <>; 24$json = <>;
24 25
25srand 0; $json = JSON::XS->new->utf8(1)->ascii(0)->encode ([join "", map +(chr rand 2555), 0..2047]); 26#srand 0; $json = JSON::XS->new->utf8(1)->ascii(0)->encode ([join "", map +(chr rand 255), 0..2047]);
26 27
27#if (1) { 28#if (1) {
28# use Storable; 29# use Storable;
29# open my $fh, "<:unix", "/opt/crossfire/share/cfserver/faces" or die "$!"; 30# open my $fh, "<:unix", "/opt/crossfire/share/cfserver/faces" or die "$!";
30# my $faces = Storable::thaw do { <$fh> }; 31# my $faces = Storable::thaw do { <$fh> };
33# print $fh2 $json; 34# print $fh2 $json;
34# warn length $json; 35# warn length $json;
35#} 36#}
36 37
37my %tst = ( 38my %tst = (
38# "JSON" => ['objToJson $perl' , 'jsonToObj $json'], 39 "JSON" => ['objToJson $perl' , 'jsonToObj $json'],
39# "JSON::DWIW" => ['$dwiw->to_json ($perl)', '$dwiw->from_json ($json)'], 40 "JSON::DWIW" => ['$dwiw->to_json ($perl)', '$dwiw->from_json ($json)'],
40# "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'], 41 "JSON::PC" => ['$pc->convert ($perl)' , '$pc->parse ($json)'],
41# "JSON::Syck" => ['JSON::Syck::Dump $perl', 'JSON::Syck::Load $json'], 42 "JSON::Syck" => ['JSON::Syck::Dump $perl', 'JSON::Syck::Load $json'],
42 "JSON::XS" => ['to_json $perl' , 'from_json $json'], 43 "JSON::XS" => ['to_json $perl' , 'from_json $json'],
43 "JSON::XS/2" => ['$xs->encode ($perl)' , '$xs->decode ($json)'], 44 "JSON::XS/2" => ['$xs2->encode ($perl)' , '$xs2->decode ($json)'],
45 "JSON::XS/3" => ['$xs3->encode ($perl)' , '$xs3->decode ($json)'],
44); 46);
45 47
46sub bench($) { 48sub bench($) {
47 my ($code) = @_; 49 my ($code) = @_;
48 50

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines