es-scout 5.3.0.es1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/AUTHORS +4 -0
  2. data/CHANGELOG +225 -0
  3. data/COPYING +340 -0
  4. data/INSTALL +18 -0
  5. data/LICENSE +6 -0
  6. data/README +66 -0
  7. data/Rakefile +74 -0
  8. data/TODO +6 -0
  9. data/bin/es-scout +10 -0
  10. data/data/cacert.pem +3154 -0
  11. data/data/code_key.pub +13 -0
  12. data/data/gpl-2.0.txt +339 -0
  13. data/data/lgpl-2.1.txt +504 -0
  14. data/lib/es-scout/command/install.rb +68 -0
  15. data/lib/es-scout/command/run.rb +56 -0
  16. data/lib/es-scout/command/test.rb +62 -0
  17. data/lib/es-scout/command/troubleshoot.rb +142 -0
  18. data/lib/es-scout/command.rb +258 -0
  19. data/lib/es-scout/plugin.rb +237 -0
  20. data/lib/es-scout/plugin_options.rb +80 -0
  21. data/lib/es-scout/scout_logger.rb +19 -0
  22. data/lib/es-scout/server.rb +578 -0
  23. data/lib/es-scout.rb +11 -0
  24. data/vendor/json_pure/CHANGES +162 -0
  25. data/vendor/json_pure/COPYING +58 -0
  26. data/vendor/json_pure/GPL +340 -0
  27. data/vendor/json_pure/README +358 -0
  28. data/vendor/json_pure/Rakefile +292 -0
  29. data/vendor/json_pure/TODO +1 -0
  30. data/vendor/json_pure/VERSION +1 -0
  31. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
  32. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
  33. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
  34. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
  35. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
  36. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
  37. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
  38. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
  39. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
  40. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
  41. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
  42. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
  43. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
  44. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
  45. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
  46. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
  47. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
  48. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
  49. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
  50. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
  51. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
  52. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
  53. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
  54. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
  55. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
  56. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
  57. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
  58. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
  59. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
  60. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
  61. data/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
  62. data/vendor/json_pure/benchmarks/generator2_benchmark.rb +222 -0
  63. data/vendor/json_pure/benchmarks/generator_benchmark.rb +224 -0
  64. data/vendor/json_pure/benchmarks/ohai.json +1216 -0
  65. data/vendor/json_pure/benchmarks/ohai.ruby +1 -0
  66. data/vendor/json_pure/benchmarks/parser2_benchmark.rb +251 -0
  67. data/vendor/json_pure/benchmarks/parser_benchmark.rb +259 -0
  68. data/vendor/json_pure/bin/edit_json.rb +9 -0
  69. data/vendor/json_pure/bin/prettify_json.rb +75 -0
  70. data/vendor/json_pure/data/example.json +1 -0
  71. data/vendor/json_pure/data/index.html +38 -0
  72. data/vendor/json_pure/data/prototype.js +4184 -0
  73. data/vendor/json_pure/ext/json/ext/generator/extconf.rb +16 -0
  74. data/vendor/json_pure/ext/json/ext/generator/generator.c +1341 -0
  75. data/vendor/json_pure/ext/json/ext/generator/generator.h +170 -0
  76. data/vendor/json_pure/ext/json/ext/parser/extconf.rb +15 -0
  77. data/vendor/json_pure/ext/json/ext/parser/parser.c +1935 -0
  78. data/vendor/json_pure/ext/json/ext/parser/parser.h +71 -0
  79. data/vendor/json_pure/ext/json/ext/parser/parser.rl +792 -0
  80. data/vendor/json_pure/install.rb +26 -0
  81. data/vendor/json_pure/lib/json/Array.xpm +21 -0
  82. data/vendor/json_pure/lib/json/FalseClass.xpm +21 -0
  83. data/vendor/json_pure/lib/json/Hash.xpm +21 -0
  84. data/vendor/json_pure/lib/json/Key.xpm +73 -0
  85. data/vendor/json_pure/lib/json/NilClass.xpm +21 -0
  86. data/vendor/json_pure/lib/json/Numeric.xpm +28 -0
  87. data/vendor/json_pure/lib/json/String.xpm +96 -0
  88. data/vendor/json_pure/lib/json/TrueClass.xpm +21 -0
  89. data/vendor/json_pure/lib/json/add/core.rb +148 -0
  90. data/vendor/json_pure/lib/json/add/rails.rb +58 -0
  91. data/vendor/json_pure/lib/json/common.rb +397 -0
  92. data/vendor/json_pure/lib/json/editor.rb +1371 -0
  93. data/vendor/json_pure/lib/json/ext.rb +15 -0
  94. data/vendor/json_pure/lib/json/json.xpm +1499 -0
  95. data/vendor/json_pure/lib/json/pure/generator.rb +452 -0
  96. data/vendor/json_pure/lib/json/pure/parser.rb +307 -0
  97. data/vendor/json_pure/lib/json/pure.rb +77 -0
  98. data/vendor/json_pure/lib/json/version.rb +8 -0
  99. data/vendor/json_pure/lib/json.rb +10 -0
  100. data/vendor/json_pure/tests/fixtures/fail1.json +1 -0
  101. data/vendor/json_pure/tests/fixtures/fail10.json +1 -0
  102. data/vendor/json_pure/tests/fixtures/fail11.json +1 -0
  103. data/vendor/json_pure/tests/fixtures/fail12.json +1 -0
  104. data/vendor/json_pure/tests/fixtures/fail13.json +1 -0
  105. data/vendor/json_pure/tests/fixtures/fail14.json +1 -0
  106. data/vendor/json_pure/tests/fixtures/fail18.json +1 -0
  107. data/vendor/json_pure/tests/fixtures/fail19.json +1 -0
  108. data/vendor/json_pure/tests/fixtures/fail2.json +1 -0
  109. data/vendor/json_pure/tests/fixtures/fail20.json +1 -0
  110. data/vendor/json_pure/tests/fixtures/fail21.json +1 -0
  111. data/vendor/json_pure/tests/fixtures/fail22.json +1 -0
  112. data/vendor/json_pure/tests/fixtures/fail23.json +1 -0
  113. data/vendor/json_pure/tests/fixtures/fail24.json +1 -0
  114. data/vendor/json_pure/tests/fixtures/fail25.json +1 -0
  115. data/vendor/json_pure/tests/fixtures/fail27.json +2 -0
  116. data/vendor/json_pure/tests/fixtures/fail28.json +2 -0
  117. data/vendor/json_pure/tests/fixtures/fail3.json +1 -0
  118. data/vendor/json_pure/tests/fixtures/fail4.json +1 -0
  119. data/vendor/json_pure/tests/fixtures/fail5.json +1 -0
  120. data/vendor/json_pure/tests/fixtures/fail6.json +1 -0
  121. data/vendor/json_pure/tests/fixtures/fail7.json +1 -0
  122. data/vendor/json_pure/tests/fixtures/fail8.json +1 -0
  123. data/vendor/json_pure/tests/fixtures/fail9.json +1 -0
  124. data/vendor/json_pure/tests/fixtures/pass1.json +56 -0
  125. data/vendor/json_pure/tests/fixtures/pass15.json +1 -0
  126. data/vendor/json_pure/tests/fixtures/pass16.json +1 -0
  127. data/vendor/json_pure/tests/fixtures/pass17.json +1 -0
  128. data/vendor/json_pure/tests/fixtures/pass2.json +1 -0
  129. data/vendor/json_pure/tests/fixtures/pass26.json +1 -0
  130. data/vendor/json_pure/tests/fixtures/pass3.json +6 -0
  131. data/vendor/json_pure/tests/test_json.rb +340 -0
  132. data/vendor/json_pure/tests/test_json_addition.rb +162 -0
  133. data/vendor/json_pure/tests/test_json_encoding.rb +68 -0
  134. data/vendor/json_pure/tests/test_json_fixtures.rb +34 -0
  135. data/vendor/json_pure/tests/test_json_generate.rb +122 -0
  136. data/vendor/json_pure/tests/test_json_rails.rb +144 -0
  137. data/vendor/json_pure/tests/test_json_unicode.rb +76 -0
  138. data/vendor/json_pure/tools/fuzz.rb +139 -0
  139. data/vendor/json_pure/tools/server.rb +61 -0
  140. metadata +233 -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,222 @@
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
+ when 'yajl'
16
+ require 'yajl'
17
+ require 'yajl/json_gem'
18
+ require 'stringio'
19
+ end
20
+
21
+ module JSON
22
+ def self.[](*) end
23
+ end
24
+
25
+ module Generator2BenchmarkCommon
26
+ include JSON
27
+
28
+ def setup
29
+ @big = eval File.read(File.join(File.dirname(__FILE__), 'ohai.ruby'))
30
+ end
31
+
32
+ def generic_reset_method
33
+ @result and @result.size >= 16 or raise @result.to_s
34
+ end
35
+ end
36
+
37
+ module JSONGeneratorCommon
38
+ include Generator2BenchmarkCommon
39
+
40
+ def benchmark_generator_fast
41
+ @result = JSON.fast_generate(@big)
42
+ end
43
+
44
+ alias reset_benchmark_generator_fast generic_reset_method
45
+
46
+ def benchmark_generator_safe
47
+ @result = JSON.generate(@big)
48
+ end
49
+
50
+ alias reset_benchmark_generator_safe generic_reset_method
51
+
52
+ def benchmark_generator_pretty
53
+ @result = JSON.pretty_generate(@big)
54
+ end
55
+
56
+ alias reset_benchmark_generator_pretty generic_reset_method
57
+
58
+ def benchmark_generator_ascii
59
+ @result = JSON.generate(@big, :ascii_only => true)
60
+ end
61
+
62
+ alias reset_benchmark_generator_ascii generic_reset_method
63
+ end
64
+
65
+ class Generator2BenchmarkExt < Bullshit::RepeatCase
66
+ include JSONGeneratorCommon
67
+
68
+ warmup yes
69
+ iterations 2000
70
+
71
+ truncate_data do
72
+ enabled false
73
+ alpha_level 0.05
74
+ window_size 50
75
+ slope_angle 0.1
76
+ end
77
+
78
+ autocorrelation do
79
+ alpha_level 0.05
80
+ max_lags 50
81
+ file yes
82
+ end
83
+
84
+
85
+ output_dir File.join(File.dirname(__FILE__), 'data')
86
+ output_filename benchmark_name + '.log'
87
+ data_file yes
88
+ histogram yes
89
+ end
90
+
91
+ class Generator2BenchmarkPure < Bullshit::RepeatCase
92
+ include JSONGeneratorCommon
93
+
94
+ warmup yes
95
+ iterations 400
96
+
97
+ truncate_data do
98
+ enabled false
99
+ alpha_level 0.05
100
+ window_size 50
101
+ slope_angle 0.1
102
+ end
103
+
104
+ autocorrelation do
105
+ alpha_level 0.05
106
+ max_lags 50
107
+ file yes
108
+ end
109
+
110
+ output_dir File.join(File.dirname(__FILE__), 'data')
111
+ output_filename benchmark_name + '.log'
112
+ data_file yes
113
+ histogram yes
114
+ end
115
+
116
+ class Generator2BenchmarkRails < Bullshit::RepeatCase
117
+ include Generator2BenchmarkCommon
118
+
119
+ warmup yes
120
+ iterations 400
121
+
122
+ truncate_data do
123
+ enabled false
124
+ alpha_level 0.05
125
+ window_size 50
126
+ slope_angle 0.1
127
+ end
128
+
129
+ autocorrelation do
130
+ alpha_level 0.05
131
+ max_lags 50
132
+ file yes
133
+ end
134
+
135
+ output_dir File.join(File.dirname(__FILE__), 'data')
136
+ output_filename benchmark_name + '.log'
137
+ data_file yes
138
+ histogram yes
139
+
140
+ def benchmark_generator
141
+ @result = @big.to_json
142
+ end
143
+
144
+ alias reset_benchmark_generator generic_reset_method
145
+ end
146
+
147
+ class Generator2BenchmarkYajl < Bullshit::RepeatCase
148
+ include Generator2BenchmarkCommon
149
+
150
+ warmup yes
151
+ iterations 2000
152
+
153
+ truncate_data do
154
+ enabled false
155
+ alpha_level 0.05
156
+ window_size 50
157
+ slope_angle 0.1
158
+ end
159
+
160
+ autocorrelation do
161
+ alpha_level 0.05
162
+ max_lags 50
163
+ file yes
164
+ end
165
+
166
+ output_dir File.join(File.dirname(__FILE__), 'data')
167
+ output_filename benchmark_name + '.log'
168
+ data_file yes
169
+ histogram yes
170
+
171
+ def benchmark_generator
172
+ output = StringIO.new
173
+ Yajl::Encoder.new.encode(@big, output)
174
+ @result = output.string
175
+ end
176
+
177
+ def benchmark_generator_gem_api
178
+ @result = @big.to_json
179
+ end
180
+
181
+ def reset_benchmark_generator
182
+ generic_reset_method
183
+ end
184
+ end
185
+
186
+ if $0 == __FILE__
187
+ Bullshit::Case.autorun false
188
+
189
+ case ARGV.first
190
+ when 'ext'
191
+ Generator2BenchmarkExt.run
192
+ when 'pure'
193
+ Generator2BenchmarkPure.run
194
+ when 'rails'
195
+ Generator2BenchmarkRails.run
196
+ when 'yajl'
197
+ Generator2BenchmarkYajl.run
198
+ else
199
+ system "#{RAKE_PATH} clean"
200
+ system "#{RUBY_PATH} #$0 rails"
201
+ system "#{RUBY_PATH} #$0 pure"
202
+ system "#{RAKE_PATH} compile_ext"
203
+ system "#{RUBY_PATH} #$0 ext"
204
+ system "#{RUBY_PATH} #$0 yajl"
205
+ Bullshit.compare do
206
+ output_filename File.join(File.dirname(__FILE__), 'data', 'Generator2BenchmarkComparison.log')
207
+
208
+ benchmark Generator2BenchmarkExt, :generator_fast, :load => yes
209
+ benchmark Generator2BenchmarkExt, :generator_safe, :load => yes
210
+ benchmark Generator2BenchmarkExt, :generator_pretty, :load => yes
211
+ benchmark Generator2BenchmarkExt, :generator_ascii, :load => yes
212
+ benchmark Generator2BenchmarkPure, :generator_fast, :load => yes
213
+ benchmark Generator2BenchmarkPure, :generator_safe, :load => yes
214
+ benchmark Generator2BenchmarkPure, :generator_pretty, :load => yes
215
+ benchmark Generator2BenchmarkPure, :generator_ascii, :load => yes
216
+ benchmark Generator2BenchmarkRails, :generator, :load => yes
217
+ benchmark Generator2BenchmarkYajl, :generator, :load => yes
218
+ benchmark Generator2BenchmarkYajl, :generator_gem_api, :load => yes
219
+ end
220
+ end
221
+ end
222
+
@@ -0,0 +1,224 @@
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
+ when 'yajl'
16
+ require 'yajl'
17
+ require 'yajl/json_gem'
18
+ require 'stringio'
19
+ end
20
+
21
+ module JSON
22
+ def self.[](*) end
23
+ end
24
+
25
+ module GeneratorBenchmarkCommon
26
+ include JSON
27
+
28
+ def setup
29
+ a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
30
+ puts a.to_json if a.respond_to?(:to_json)
31
+ @big = a * 100
32
+ end
33
+
34
+ def generic_reset_method
35
+ @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
36
+ end
37
+ end
38
+
39
+ module JSONGeneratorCommon
40
+ include GeneratorBenchmarkCommon
41
+
42
+ def benchmark_generator_fast
43
+ @result = JSON.fast_generate(@big)
44
+ end
45
+
46
+ alias reset_benchmark_generator_fast generic_reset_method
47
+
48
+ def benchmark_generator_safe
49
+ @result = JSON.generate(@big)
50
+ end
51
+
52
+ alias reset_benchmark_generator_safe generic_reset_method
53
+
54
+ def benchmark_generator_pretty
55
+ @result = JSON.pretty_generate(@big)
56
+ end
57
+
58
+ alias reset_benchmark_generator_pretty generic_reset_method
59
+
60
+ def benchmark_generator_ascii
61
+ @result = JSON.generate(@big, :ascii_only => true)
62
+ end
63
+
64
+ alias reset_benchmark_generator_ascii generic_reset_method
65
+ end
66
+
67
+ class GeneratorBenchmarkExt < Bullshit::RepeatCase
68
+ include JSONGeneratorCommon
69
+
70
+ warmup yes
71
+ iterations 2000
72
+
73
+ truncate_data do
74
+ enabled false
75
+ alpha_level 0.05
76
+ window_size 50
77
+ slope_angle 0.1
78
+ end
79
+
80
+ autocorrelation do
81
+ alpha_level 0.05
82
+ max_lags 50
83
+ file yes
84
+ end
85
+
86
+
87
+ output_dir File.join(File.dirname(__FILE__), 'data')
88
+ output_filename benchmark_name + '.log'
89
+ data_file yes
90
+ histogram yes
91
+ end
92
+
93
+ class GeneratorBenchmarkPure < Bullshit::RepeatCase
94
+ include JSONGeneratorCommon
95
+
96
+ warmup yes
97
+ iterations 400
98
+
99
+ truncate_data do
100
+ enabled false
101
+ alpha_level 0.05
102
+ window_size 50
103
+ slope_angle 0.1
104
+ end
105
+
106
+ autocorrelation do
107
+ alpha_level 0.05
108
+ max_lags 50
109
+ file yes
110
+ end
111
+
112
+ output_dir File.join(File.dirname(__FILE__), 'data')
113
+ output_filename benchmark_name + '.log'
114
+ data_file yes
115
+ histogram yes
116
+ end
117
+
118
+ class GeneratorBenchmarkRails < Bullshit::RepeatCase
119
+ include GeneratorBenchmarkCommon
120
+
121
+ warmup yes
122
+ iterations 400
123
+
124
+ truncate_data do
125
+ enabled false
126
+ alpha_level 0.05
127
+ window_size 50
128
+ slope_angle 0.1
129
+ end
130
+
131
+ autocorrelation do
132
+ alpha_level 0.05
133
+ max_lags 50
134
+ file yes
135
+ end
136
+
137
+ output_dir File.join(File.dirname(__FILE__), 'data')
138
+ output_filename benchmark_name + '.log'
139
+ data_file yes
140
+ histogram yes
141
+
142
+ def benchmark_generator
143
+ @result = @big.to_json
144
+ end
145
+
146
+ alias reset_benchmark_generator generic_reset_method
147
+ end
148
+
149
+ class GeneratorBenchmarkYajl < Bullshit::RepeatCase
150
+ include GeneratorBenchmarkCommon
151
+
152
+ warmup yes
153
+ iterations 2000
154
+
155
+ truncate_data do
156
+ enabled false
157
+ alpha_level 0.05
158
+ window_size 50
159
+ slope_angle 0.1
160
+ end
161
+
162
+ autocorrelation do
163
+ alpha_level 0.05
164
+ max_lags 50
165
+ file yes
166
+ end
167
+
168
+ output_dir File.join(File.dirname(__FILE__), 'data')
169
+ output_filename benchmark_name + '.log'
170
+ data_file yes
171
+ histogram yes
172
+
173
+ def benchmark_generator
174
+ output = StringIO.new
175
+ Yajl::Encoder.new.encode(@big, output)
176
+ @result = output.string
177
+ end
178
+
179
+ def benchmark_generator_gem_api
180
+ @result = @big.to_json
181
+ end
182
+
183
+ def reset_benchmark_generator
184
+ generic_reset_method
185
+ end
186
+ end
187
+
188
+ if $0 == __FILE__
189
+ Bullshit::Case.autorun false
190
+
191
+ case ARGV.first
192
+ when 'ext'
193
+ GeneratorBenchmarkExt.run
194
+ when 'pure'
195
+ GeneratorBenchmarkPure.run
196
+ when 'rails'
197
+ GeneratorBenchmarkRails.run
198
+ when 'yajl'
199
+ GeneratorBenchmarkYajl.run
200
+ else
201
+ system "#{RAKE_PATH} clean"
202
+ system "#{RUBY_PATH} #$0 rails"
203
+ system "#{RUBY_PATH} #$0 pure"
204
+ system "#{RAKE_PATH} compile_ext"
205
+ system "#{RUBY_PATH} #$0 ext"
206
+ system "#{RUBY_PATH} #$0 yajl"
207
+ Bullshit.compare do
208
+ output_filename File.join(File.dirname(__FILE__), 'data', 'GeneratorBenchmarkComparison.log')
209
+
210
+ benchmark GeneratorBenchmarkExt, :generator_fast, :load => yes
211
+ benchmark GeneratorBenchmarkExt, :generator_safe, :load => yes
212
+ benchmark GeneratorBenchmarkExt, :generator_pretty, :load => yes
213
+ benchmark GeneratorBenchmarkExt, :generator_ascii, :load => yes
214
+ benchmark GeneratorBenchmarkPure, :generator_fast, :load => yes
215
+ benchmark GeneratorBenchmarkPure, :generator_safe, :load => yes
216
+ benchmark GeneratorBenchmarkPure, :generator_pretty, :load => yes
217
+ benchmark GeneratorBenchmarkPure, :generator_ascii, :load => yes
218
+ benchmark GeneratorBenchmarkRails, :generator, :load => yes
219
+ benchmark GeneratorBenchmarkYajl, :generator, :load => yes
220
+ benchmark GeneratorBenchmarkYajl, :generator_gem_api, :load => yes
221
+ end
222
+ end
223
+ end
224
+