]>
Dogcows Code - chaz/p5-CGI-Ex/blob - samples/benchmark/bench_jsondump.pl
3 # Benchmark: running cejd, json, zejd for at least 2 CPU seconds...
4 # cejd: 4 wallclock secs ( 2.18 usr + 0.00 sys = 2.18 CPU) @ 7045.87/s (n=15360)
5 # json: 3 wallclock secs ( 2.16 usr + 0.00 sys = 2.16 CPU) @ 6634.26/s (n=14330)
6 # zejd: 3 wallclock secs ( 2.16 usr + 0.00 sys = 2.16 CPU) @ 6634.26/s (n=14330)
8 # zejd 6634/s -- 0% -6%
9 # json 6634/s 0% -- -6%
10 # cejd 7046/s 6% 6% --
12 # Benchmark: running cejd, json for at least 2 CPU seconds...
13 # cejd: 3 wallclock secs ( 2.04 usr + 0.00 sys = 2.04 CPU) @ 5690.20/s (n=11608)
14 # json: 2 wallclock secs ( 2.06 usr + 0.00 sys = 2.06 CPU) @ 5291.75/s (n=10901)
19 # Benchmark: running cejd, json for at least 2 CPU seconds...
20 # cejd: 4 wallclock secs ( 2.21 usr + 0.00 sys = 2.21 CPU) @ 24320.81/s (n=53749)
21 # json: 3 wallclock secs ( 2.14 usr + 0.00 sys = 2.14 CPU) @ 10048.13/s (n=21503)
23 # json 10048/s -- -59%
24 # cejd 24321/s 142% --
28 use Benchmark
qw(cmpthese timethese);
30 use CGI
::Ex
::JSONDump
;
32 my $json = JSON-
>new(pretty
=> 0, keysort
=> 0);
33 my $cejd = CGI
::Ex
::JSONDump-
>new({pretty
=> 0, no_sort
=> 1});
44 print "JSON\n--------------------\n". $json->objToJson($data)."\n----------------------------\n";
45 print "CEJD\n--------------------\n". $cejd->dump($data) ."\n----------------------------\n";
47 cmpthese timethese
(-2, {
48 json
=> sub { my $a = $json->objToJson($data) },
49 cejd
=> sub { my $a = $cejd->dump($data) },
50 zejd
=> sub { my $a = $cejd->dump($data) },
53 ###----------------------------------------------------------------###
55 $json = JSON-
>new(pretty
=> 1, keysort
=> 1);
56 $cejd = CGI
::Ex
::JSONDump-
>new({pretty
=> 1});
63 six
=> '12345678901234567890',
67 print "JSON\n--------------------\n". $json->objToJson($data)."\n----------------------------\n";
68 print "CEJD\n--------------------\n". $cejd->dump($data) ."\n----------------------------\n";
70 cmpthese timethese
(-2, {
71 json
=> sub { my $a = $json->objToJson($data) },
72 cejd
=> sub { my $a = $cejd->dump($data) },
75 ###----------------------------------------------------------------###
77 $json = JSON-
>new(pretty
=> 1);
78 $cejd = CGI
::Ex
::JSONDump-
>new({pretty
=> 1});
80 $data = ["foo\n<script>\nThis is sort of \"odd\"\n</script>"];
82 print "JSON\n--------------------\n". $json->objToJson($data)."\n----------------------------\n";
83 print "CEJD\n--------------------\n". $cejd->dump($data) ."\n----------------------------\n";
85 cmpthese timethese
(-2, {
86 json
=> sub { my $a = $json->objToJson($data) },
87 cejd
=> sub { my $a = $cejd->dump($data) },
This page took 0.039747 seconds and 4 git commands to generate.