json 1.1.5-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of json might be problematic. Click here for more details.
- data/CHANGES +106 -0
- data/GPL +340 -0
- data/README +78 -0
- data/RUBY +58 -0
- data/Rakefile +268 -0
- data/TODO +1 -0
- data/VERSION +1 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/benchmarks/generator_benchmark.rb +165 -0
- data/benchmarks/parser_benchmark.rb +197 -0
- data/bin/edit_json.rb +9 -0
- data/bin/prettify_json.rb +75 -0
- data/data/example.json +1 -0
- data/data/index.html +38 -0
- data/data/prototype.js +4184 -0
- data/doc-templates/main.txt +283 -0
- data/ext/json/ext/generator/extconf.rb +11 -0
- data/ext/json/ext/generator/generator.c +919 -0
- data/ext/json/ext/generator/unicode.c +182 -0
- data/ext/json/ext/generator/unicode.h +53 -0
- data/ext/json/ext/parser/extconf.rb +11 -0
- data/ext/json/ext/parser/parser.c +1829 -0
- data/ext/json/ext/parser/parser.rl +686 -0
- data/ext/json/ext/parser/unicode.c +154 -0
- data/ext/json/ext/parser/unicode.h +58 -0
- data/install.rb +26 -0
- data/lib/json.rb +10 -0
- data/lib/json/Array.xpm +21 -0
- data/lib/json/FalseClass.xpm +21 -0
- data/lib/json/Hash.xpm +21 -0
- data/lib/json/Key.xpm +73 -0
- data/lib/json/NilClass.xpm +21 -0
- data/lib/json/Numeric.xpm +28 -0
- data/lib/json/String.xpm +96 -0
- data/lib/json/TrueClass.xpm +21 -0
- data/lib/json/add/core.rb +135 -0
- data/lib/json/add/rails.rb +58 -0
- data/lib/json/common.rb +354 -0
- data/lib/json/editor.rb +1371 -0
- data/lib/json/ext.rb +15 -0
- data/lib/json/ext/generator.so +0 -0
- data/lib/json/ext/parser.so +0 -0
- data/lib/json/json.xpm +1499 -0
- data/lib/json/pure.rb +77 -0
- data/lib/json/pure/generator.rb +430 -0
- data/lib/json/pure/parser.rb +267 -0
- data/lib/json/version.rb +8 -0
- data/tests/fixtures/fail1.json +1 -0
- data/tests/fixtures/fail10.json +1 -0
- data/tests/fixtures/fail11.json +1 -0
- data/tests/fixtures/fail12.json +1 -0
- data/tests/fixtures/fail13.json +1 -0
- data/tests/fixtures/fail14.json +1 -0
- data/tests/fixtures/fail18.json +1 -0
- data/tests/fixtures/fail19.json +1 -0
- data/tests/fixtures/fail2.json +1 -0
- data/tests/fixtures/fail20.json +1 -0
- data/tests/fixtures/fail21.json +1 -0
- data/tests/fixtures/fail22.json +1 -0
- data/tests/fixtures/fail23.json +1 -0
- data/tests/fixtures/fail24.json +1 -0
- data/tests/fixtures/fail25.json +1 -0
- data/tests/fixtures/fail27.json +2 -0
- data/tests/fixtures/fail28.json +2 -0
- data/tests/fixtures/fail3.json +1 -0
- data/tests/fixtures/fail4.json +1 -0
- data/tests/fixtures/fail5.json +1 -0
- data/tests/fixtures/fail6.json +1 -0
- data/tests/fixtures/fail7.json +1 -0
- data/tests/fixtures/fail8.json +1 -0
- data/tests/fixtures/fail9.json +1 -0
- data/tests/fixtures/pass1.json +56 -0
- data/tests/fixtures/pass15.json +1 -0
- data/tests/fixtures/pass16.json +1 -0
- data/tests/fixtures/pass17.json +1 -0
- data/tests/fixtures/pass2.json +1 -0
- data/tests/fixtures/pass26.json +1 -0
- data/tests/fixtures/pass3.json +6 -0
- data/tests/test_json.rb +312 -0
- data/tests/test_json_addition.rb +164 -0
- data/tests/test_json_fixtures.rb +34 -0
- data/tests/test_json_generate.rb +106 -0
- data/tests/test_json_rails.rb +146 -0
- data/tests/test_json_unicode.rb +62 -0
- data/tools/fuzz.rb +139 -0
- data/tools/server.rb +61 -0
- metadata +200 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
========================== 2009-04-01T16:46:41 CEST ===========================
|
2
|
+
Benchmarking on ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux].
|
3
|
+
Running 'ParserBenchmarkYAML' for 1000 iterations/method (compare_time=real)
|
4
|
+
===============================================================================
|
5
|
+
|
6
|
+
This first run is only for warmup.
|
7
|
+
ParserBenchmarkYAML#parser:
|
8
|
+
real total user system
|
9
|
+
sum 4.506546021 4.490000000 4.480000000 0.010000000
|
10
|
+
min 0.003598928 0.000000000 0.000000000 0.000000000
|
11
|
+
std- 0.000288588 -0.001817113 -0.001826296 -0.000306228
|
12
|
+
mean 0.004506546 0.004490000 0.004480000 0.000010000
|
13
|
+
std+ 0.008724504 0.010797113 0.010786296 0.000326228
|
14
|
+
max 0.042540073 0.040000000 0.040000000 0.010000000
|
15
|
+
std 0.004217958 0.006307113 0.006306296 0.000316228
|
16
|
+
std% 93.596247306 140.470232048 140.765535944 3162.277660168
|
17
|
+
harm 0.003882332 nan nan nan
|
18
|
+
geo 0.004019118 0.000000000 0.000000000 0.000000000
|
19
|
+
q1 0.003660917 0.000000000 0.000000000 0.000000000
|
20
|
+
med 0.003705978 0.000000000 0.000000000 0.000000000
|
21
|
+
q3 0.003748715 0.010000000 0.010000000 0.000000000
|
22
|
+
1000 221.89943 0.004506546
|
23
|
+
calls calls/sec secs/call
|
24
|
+
|
25
|
+
0.04059 -|
|
26
|
+
0.03670 -|
|
27
|
+
0.03280 -|
|
28
|
+
0.02891 -|*
|
29
|
+
0.02502 -|
|
30
|
+
0.02112 -|
|
31
|
+
0.01723 -|
|
32
|
+
0.01333 -|
|
33
|
+
0.00944 -|
|
34
|
+
0.00555 -|**************************************************
|
35
|
+
|
36
|
+
Outliers detected with box plot algo (median=0.00371, iqr=0.00009, factor=3.00):
|
37
|
+
high=56 very_high=119
|
38
|
+
|
39
|
+
Ljung-Box statistics: q=433.20488 (alpha=0.05, df=50).
|
40
|
+
1.00000 >= 0.95000 => Autocorrelation was detected.
|
41
|
+
|
42
|
+
ParserBenchmarkYAML#parser:
|
43
|
+
real total user system
|
44
|
+
sum 4.454077959 4.430000000 4.420000000 0.010000000
|
45
|
+
min 0.003582954 0.000000000 0.000000000 0.000000000
|
46
|
+
std- 0.000263948 -0.001903657 -0.001912749 -0.000306228
|
47
|
+
mean 0.004454078 0.004430000 0.004420000 0.000010000
|
48
|
+
std+ 0.008644208 0.010763657 0.010752749 0.000326228
|
49
|
+
max 0.035927057 0.040000000 0.040000000 0.010000000
|
50
|
+
std 0.004190130 0.006333657 0.006332749 0.000316228
|
51
|
+
std% 94.074019869 142.971948832 143.274853190 3162.277660168
|
52
|
+
harm 0.003836471 nan nan nan
|
53
|
+
geo 0.003968258 0.000000000 0.000000000 0.000000000
|
54
|
+
q1 0.003650367 0.000000000 0.000000000 0.000000000
|
55
|
+
med 0.003690004 0.000000000 0.000000000 0.000000000
|
56
|
+
q3 0.003731966 0.010000000 0.010000000 0.000000000
|
57
|
+
1000 224.51336 0.004454078
|
58
|
+
calls calls/sec secs/call
|
59
|
+
|
60
|
+
0.03431 -|
|
61
|
+
0.03108 -|*
|
62
|
+
0.02784 -|*
|
63
|
+
0.02461 -|
|
64
|
+
0.02137 -|
|
65
|
+
0.01814 -|
|
66
|
+
0.01490 -|
|
67
|
+
0.01167 -|
|
68
|
+
0.00843 -|
|
69
|
+
0.00520 -|**************************************************
|
70
|
+
|
71
|
+
Outliers detected with box plot algo (median=0.00369, iqr=0.00008, factor=3.00):
|
72
|
+
high=58 very_high=100
|
73
|
+
|
74
|
+
Ljung-Box statistics: q=451.12745 (alpha=0.05, df=50).
|
75
|
+
1.00000 >= 0.95000 => Autocorrelation was detected.
|
76
|
+
|
77
|
+
No initial data truncated.
|
78
|
+
=> System may have been in a steady state from the beginning.
|
79
|
+
========================== 2009-04-01T16:46:54 CEST ===========================
|
80
|
+
|
81
|
+
Writing measurement data file '/data/scm/json/benchmarks/data/ParserBenchmarkYAML#parser.dat'.
|
82
|
+
Writing autocorrelation plot file '/data/scm/json/benchmarks/data/ParserBenchmarkYAML#parser-autocorrelation.dat'.
|
@@ -0,0 +1,165 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# CODING: UTF-8
|
3
|
+
|
4
|
+
require 'rbconfig'
|
5
|
+
RUBY_PATH=File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
6
|
+
RAKE_PATH=File.join(Config::CONFIG['bindir'], 'rake')
|
7
|
+
require 'bullshit'
|
8
|
+
case ARGV.first
|
9
|
+
when 'ext'
|
10
|
+
require 'json/ext'
|
11
|
+
when 'pure'
|
12
|
+
require 'json/pure'
|
13
|
+
when 'rails'
|
14
|
+
require 'active_support'
|
15
|
+
end
|
16
|
+
|
17
|
+
module JSON
|
18
|
+
def self.[](*) end
|
19
|
+
end
|
20
|
+
|
21
|
+
module GeneratorBenchmarkCommon
|
22
|
+
include JSON
|
23
|
+
|
24
|
+
def setup
|
25
|
+
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
26
|
+
puts a.to_json
|
27
|
+
@big = a * 100
|
28
|
+
end
|
29
|
+
|
30
|
+
def generic_reset_method
|
31
|
+
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module JSONGeneratorCommon
|
36
|
+
include GeneratorBenchmarkCommon
|
37
|
+
|
38
|
+
def benchmark_generator_fast
|
39
|
+
@result = JSON.fast_generate(@big)
|
40
|
+
end
|
41
|
+
|
42
|
+
alias reset_benchmark_generator_fast generic_reset_method
|
43
|
+
|
44
|
+
def benchmark_generator_safe
|
45
|
+
@result = JSON.generate(@big)
|
46
|
+
end
|
47
|
+
|
48
|
+
alias reset_benchmark_generator_safe generic_reset_method
|
49
|
+
|
50
|
+
def benchmark_generator_pretty
|
51
|
+
@result = JSON.pretty_generate(@big)
|
52
|
+
end
|
53
|
+
|
54
|
+
alias reset_benchmark_generator_pretty generic_reset_method
|
55
|
+
end
|
56
|
+
|
57
|
+
class GeneratorBenchmarkExt < Bullshit::RepeatCase
|
58
|
+
include JSONGeneratorCommon
|
59
|
+
|
60
|
+
warmup yes
|
61
|
+
iterations 1000
|
62
|
+
|
63
|
+
truncate_data do
|
64
|
+
alpha_level 0.05
|
65
|
+
window_size 50
|
66
|
+
slope_angle 0.1
|
67
|
+
end
|
68
|
+
|
69
|
+
autocorrelation do
|
70
|
+
alpha_level 0.05
|
71
|
+
max_lags 50
|
72
|
+
file yes
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
77
|
+
output_filename benchmark_name + '.log'
|
78
|
+
data_file yes
|
79
|
+
histogram yes
|
80
|
+
end
|
81
|
+
|
82
|
+
class GeneratorBenchmarkPure < Bullshit::RepeatCase
|
83
|
+
include JSONGeneratorCommon
|
84
|
+
|
85
|
+
warmup yes
|
86
|
+
iterations 1000
|
87
|
+
|
88
|
+
truncate_data do
|
89
|
+
alpha_level 0.05
|
90
|
+
window_size 50
|
91
|
+
slope_angle 0.1
|
92
|
+
end
|
93
|
+
|
94
|
+
autocorrelation do
|
95
|
+
alpha_level 0.05
|
96
|
+
max_lags 50
|
97
|
+
file yes
|
98
|
+
end
|
99
|
+
|
100
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
101
|
+
output_filename benchmark_name + '.log'
|
102
|
+
data_file yes
|
103
|
+
histogram yes
|
104
|
+
end
|
105
|
+
|
106
|
+
class GeneratorBenchmarkRails < Bullshit::RepeatCase
|
107
|
+
include GeneratorBenchmarkCommon
|
108
|
+
|
109
|
+
warmup yes
|
110
|
+
iterations 1000
|
111
|
+
|
112
|
+
truncate_data do
|
113
|
+
alpha_level 0.05
|
114
|
+
window_size 50
|
115
|
+
slope_angle 0.1
|
116
|
+
end
|
117
|
+
|
118
|
+
autocorrelation do
|
119
|
+
alpha_level 0.05
|
120
|
+
max_lags 50
|
121
|
+
file yes
|
122
|
+
end
|
123
|
+
|
124
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
125
|
+
output_filename benchmark_name + '.log'
|
126
|
+
data_file yes
|
127
|
+
histogram yes
|
128
|
+
|
129
|
+
def benchmark_generator
|
130
|
+
@result = @big.to_json
|
131
|
+
end
|
132
|
+
|
133
|
+
alias reset_benchmark_generator generic_reset_method
|
134
|
+
end
|
135
|
+
|
136
|
+
if $0 == __FILE__
|
137
|
+
Bullshit::Case.autorun false
|
138
|
+
|
139
|
+
case ARGV.first
|
140
|
+
when 'ext'
|
141
|
+
GeneratorBenchmarkExt.run
|
142
|
+
when 'pure'
|
143
|
+
GeneratorBenchmarkPure.run
|
144
|
+
when 'rails'
|
145
|
+
GeneratorBenchmarkRails.run
|
146
|
+
else
|
147
|
+
system "#{RAKE_PATH} clean"
|
148
|
+
system "#{RUBY_PATH} #$0 rails"
|
149
|
+
system "#{RUBY_PATH} #$0 pure"
|
150
|
+
system "#{RAKE_PATH} compile"
|
151
|
+
system "#{RUBY_PATH} #$0 ext"
|
152
|
+
Bullshit.compare do
|
153
|
+
output_filename File.join(File.dirname(__FILE__), 'data', 'GeneratorBenchmarkComparison.log')
|
154
|
+
|
155
|
+
benchmark GeneratorBenchmarkExt, :generator_fast, :load => yes
|
156
|
+
benchmark GeneratorBenchmarkExt, :generator_safe, :load => yes
|
157
|
+
benchmark GeneratorBenchmarkExt, :generator_pretty, :load => yes
|
158
|
+
benchmark GeneratorBenchmarkPure, :generator_fast, :load => yes
|
159
|
+
benchmark GeneratorBenchmarkPure, :generator_safe, :load => yes
|
160
|
+
benchmark GeneratorBenchmarkPure, :generator_pretty, :load => yes
|
161
|
+
benchmark GeneratorBenchmarkRails, :generator, :load => yes
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
@@ -0,0 +1,197 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# CODING: UTF-8
|
3
|
+
|
4
|
+
require 'rbconfig'
|
5
|
+
RUBY_PATH=File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
6
|
+
RAKE_PATH=File.join(Config::CONFIG['bindir'], 'rake')
|
7
|
+
require 'bullshit'
|
8
|
+
case ARGV.first
|
9
|
+
when 'ext'
|
10
|
+
require 'json/ext'
|
11
|
+
when 'pure'
|
12
|
+
require 'json/pure'
|
13
|
+
when 'yaml'
|
14
|
+
require 'yaml'
|
15
|
+
require 'json/pure'
|
16
|
+
when 'rails'
|
17
|
+
require 'active_support'
|
18
|
+
require 'json/pure'
|
19
|
+
else
|
20
|
+
require 'json/pure'
|
21
|
+
end
|
22
|
+
|
23
|
+
module ParserBenchmarkCommon
|
24
|
+
include JSON
|
25
|
+
|
26
|
+
def setup
|
27
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
28
|
+
@big = a * 100
|
29
|
+
@json = JSON.generate(@big)
|
30
|
+
end
|
31
|
+
|
32
|
+
def generic_reset_method
|
33
|
+
@result == @big or raise "not equal"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class ParserBenchmarkExt < Bullshit::RepeatCase
|
38
|
+
include ParserBenchmarkCommon
|
39
|
+
|
40
|
+
warmup yes
|
41
|
+
iterations 1000
|
42
|
+
|
43
|
+
truncate_data do
|
44
|
+
alpha_level 0.05
|
45
|
+
window_size 50
|
46
|
+
slope_angle 0.1
|
47
|
+
end
|
48
|
+
|
49
|
+
autocorrelation do
|
50
|
+
alpha_level 0.05
|
51
|
+
max_lags 50
|
52
|
+
file yes
|
53
|
+
end
|
54
|
+
|
55
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
56
|
+
output_filename benchmark_name + '.log'
|
57
|
+
data_file yes
|
58
|
+
histogram yes
|
59
|
+
|
60
|
+
def benchmark_parser
|
61
|
+
@result = JSON.parse(@json)
|
62
|
+
end
|
63
|
+
|
64
|
+
alias reset_parser generic_reset_method
|
65
|
+
end
|
66
|
+
|
67
|
+
class ParserBenchmarkPure < Bullshit::RepeatCase
|
68
|
+
include ParserBenchmarkCommon
|
69
|
+
|
70
|
+
warmup yes
|
71
|
+
iterations 1000
|
72
|
+
|
73
|
+
truncate_data do
|
74
|
+
alpha_level 0.05
|
75
|
+
window_size 50
|
76
|
+
slope_angle 0.1
|
77
|
+
end
|
78
|
+
|
79
|
+
autocorrelation do
|
80
|
+
alpha_level 0.05
|
81
|
+
max_lags 50
|
82
|
+
file yes
|
83
|
+
end
|
84
|
+
|
85
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
86
|
+
output_filename benchmark_name + '.log'
|
87
|
+
data_file yes
|
88
|
+
histogram yes
|
89
|
+
|
90
|
+
def benchmark_parser
|
91
|
+
@result = JSON.parse(@json)
|
92
|
+
end
|
93
|
+
|
94
|
+
alias reset_parser generic_reset_method
|
95
|
+
end
|
96
|
+
|
97
|
+
class ParserBenchmarkYAML < Bullshit::RepeatCase
|
98
|
+
warmup yes
|
99
|
+
iterations 1000
|
100
|
+
|
101
|
+
truncate_data do
|
102
|
+
alpha_level 0.05
|
103
|
+
window_size 50
|
104
|
+
slope_angle 0.1
|
105
|
+
end
|
106
|
+
|
107
|
+
autocorrelation do
|
108
|
+
alpha_level 0.05
|
109
|
+
max_lags 50
|
110
|
+
file yes
|
111
|
+
end
|
112
|
+
|
113
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
114
|
+
output_filename benchmark_name + '.log'
|
115
|
+
data_file yes
|
116
|
+
histogram yes
|
117
|
+
|
118
|
+
def setup
|
119
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
120
|
+
@big = a * 100
|
121
|
+
@json = JSON.pretty_generate(@big)
|
122
|
+
end
|
123
|
+
|
124
|
+
def benchmark_parser
|
125
|
+
@result = YAML.load(@json)
|
126
|
+
end
|
127
|
+
|
128
|
+
def generic_reset_method
|
129
|
+
@result == @big or raise "not equal"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class ParserBenchmarkRails < Bullshit::RepeatCase
|
134
|
+
warmup yes
|
135
|
+
iterations 1000
|
136
|
+
|
137
|
+
truncate_data do
|
138
|
+
alpha_level 0.05
|
139
|
+
window_size 50
|
140
|
+
slope_angle 0.1
|
141
|
+
end
|
142
|
+
|
143
|
+
autocorrelation do
|
144
|
+
alpha_level 0.05
|
145
|
+
max_lags 50
|
146
|
+
file yes
|
147
|
+
end
|
148
|
+
|
149
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
150
|
+
output_filename benchmark_name + '.log'
|
151
|
+
data_file yes
|
152
|
+
histogram yes
|
153
|
+
|
154
|
+
def setup
|
155
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
156
|
+
@big = a * 100
|
157
|
+
@json = JSON.generate(@big)
|
158
|
+
end
|
159
|
+
|
160
|
+
def benchmark_parser
|
161
|
+
@result = ActiveSupport::JSON.decode(@json)
|
162
|
+
end
|
163
|
+
|
164
|
+
def generic_reset_method
|
165
|
+
@result == @big or raise "not equal"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
if $0 == __FILE__
|
170
|
+
Bullshit::Case.autorun false
|
171
|
+
|
172
|
+
case ARGV.first
|
173
|
+
when 'ext'
|
174
|
+
ParserBenchmarkExt.run
|
175
|
+
when 'pure'
|
176
|
+
ParserBenchmarkPure.run
|
177
|
+
when 'yaml'
|
178
|
+
ParserBenchmarkYAML.run
|
179
|
+
when 'rails'
|
180
|
+
ParserBenchmarkRails.run
|
181
|
+
else
|
182
|
+
system "#{RAKE_PATH} clean"
|
183
|
+
system "#{RUBY_PATH} #$0 yaml"
|
184
|
+
system "#{RUBY_PATH} #$0 rails"
|
185
|
+
system "#{RUBY_PATH} #$0 pure"
|
186
|
+
system "#{RAKE_PATH} compile"
|
187
|
+
system "#{RUBY_PATH} #$0 ext"
|
188
|
+
Bullshit.compare do
|
189
|
+
output_filename File.join(File.dirname(__FILE__), 'data', 'ParserBenchmarkComparison.log')
|
190
|
+
|
191
|
+
benchmark ParserBenchmarkExt, :parser, :load => yes
|
192
|
+
benchmark ParserBenchmarkPure, :parser, :load => yes
|
193
|
+
benchmark ParserBenchmarkYAML, :parser, :load => yes
|
194
|
+
benchmark ParserBenchmarkRails, :parser, :load => yes
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|