]>
Dogcows Code - chaz/p5-CGI-Ex/blob - samples/benchmark/bench_jsondump.pl
bb6e2e61fbf545ba5fa12cd092902e25c81ab402
3 # As of JSON switch to 2.0 and new JSON interface
4 # Benchmark: running cejd, json, zejd for at least 2 CPU seconds...
5 # cejd: 3 wallclock secs ( 2.17 usr + 0.00 sys = 2.17 CPU) @ 7078.34/s (n=15360)
6 # json: 3 wallclock secs ( 2.24 usr + 0.00 sys = 2.24 CPU) @ 8723.21/s (n=19540)
7 # zejd: 3 wallclock secs ( 2.16 usr + 0.00 sys = 2.16 CPU) @ 7111.11/s (n=15360)
9 # cejd 7078/s -- -0% -19%
10 # zejd 7111/s 0% -- -18%
11 # json 8723/s 23% 23% --
13 # Benchmark: running cejd, json for at least 2 CPU seconds...
14 # cejd: 3 wallclock secs ( 2.08 usr + 0.00 sys = 2.08 CPU) @ 5800.48/s (n=12065)
15 # json: 2 wallclock secs ( 2.13 usr + 0.00 sys = 2.13 CPU) @ 7206.57/s (n=15350)
20 # Benchmark: running cejd, json for at least 2 CPU seconds...
21 # cejd: 2 wallclock secs ( 2.06 usr + 0.00 sys = 2.06 CPU) @ 30656.31/s (n=63152)
22 # json: 2 wallclock secs ( 2.08 usr + 0.00 sys = 2.08 CPU) @ 24666.35/s (n=51306)
24 # json 24666/s -- -20%
31 use Benchmark
qw(cmpthese timethese);
33 use CGI
::Ex
::JSONDump
;
38 my $cejd = CGI
::Ex
::JSONDump-
>new;
49 print "JSON\n--------------------\n". $json->encode($data)."\n----------------------------\n";
50 print "CEJD\n--------------------\n". $cejd->dump($data) ."\n----------------------------\n";
52 cmpthese timethese
(-2, {
53 json
=> sub { my $a = $json->encode($data) },
54 cejd
=> sub { my $a = $cejd->dump($data) },
55 zejd
=> sub { my $a = $cejd->dump($data) },
58 ###----------------------------------------------------------------###
63 $cejd = CGI
::Ex
::JSONDump-
>new({pretty
=> 1});
70 six
=> '12345678901234567890',
74 print "JSON\n--------------------\n". $json->encode($data)."\n----------------------------\n";
75 print "CEJD\n--------------------\n". $cejd->dump($data) ."\n----------------------------\n";
77 cmpthese timethese
(-2, {
78 json
=> sub { my $a = $json->encode($data) },
79 cejd
=> sub { my $a = $cejd->dump($data) },
82 ###----------------------------------------------------------------###
87 $cejd = CGI
::Ex
::JSONDump-
>new({pretty
=> 1, no_tag_splitting
=> 1});
89 $data = ["foo\n<script>\nThis is sort of \"odd\"\n</script>"];
91 print "JSON\n--------------------\n". $json->encode($data)."\n----------------------------\n";
92 print "CEJD\n--------------------\n". $cejd->dump($data) ."\n----------------------------\n";
94 cmpthese timethese
(-2, {
95 json
=> sub { my $a = $json->encode($data) },
96 cejd
=> sub { my $a = $cejd->dump($data) },
This page took 0.039602 seconds and 4 git commands to generate.