json 1.0.0 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES.md +503 -0
- data/LICENSE +56 -0
- data/README.md +416 -0
- data/ext/json/ext/fbuffer/fbuffer.h +187 -0
- data/ext/json/ext/generator/depend +1 -0
- data/ext/json/ext/generator/extconf.rb +2 -7
- data/ext/json/ext/generator/generator.c +1312 -338
- data/ext/json/ext/generator/generator.h +177 -0
- data/ext/json/ext/parser/depend +1 -0
- data/ext/json/ext/parser/extconf.rb +28 -5
- data/ext/json/ext/parser/parser.c +1349 -689
- data/ext/json/ext/parser/parser.h +96 -0
- data/ext/json/ext/parser/parser.rl +644 -188
- data/ext/json/extconf.rb +3 -0
- data/json.gemspec +68 -0
- data/lib/json/add/bigdecimal.rb +58 -0
- data/lib/json/add/complex.rb +51 -0
- data/lib/json/add/core.rb +12 -0
- data/lib/json/add/date.rb +54 -0
- data/lib/json/add/date_time.rb +67 -0
- data/lib/json/add/exception.rb +49 -0
- data/lib/json/add/ostruct.rb +54 -0
- data/lib/json/add/range.rb +54 -0
- data/lib/json/add/rational.rb +49 -0
- data/lib/json/add/regexp.rb +48 -0
- data/lib/json/add/set.rb +48 -0
- data/lib/json/add/struct.rb +52 -0
- data/lib/json/add/symbol.rb +48 -0
- data/lib/json/add/time.rb +59 -0
- data/lib/json/common.rb +588 -74
- data/lib/json/ext.rb +3 -1
- data/lib/json/generic_object.rb +75 -0
- data/lib/json/pure/generator.rb +311 -119
- data/lib/json/pure/parser.rb +182 -55
- data/lib/json/pure.rb +5 -65
- data/lib/json/version.rb +2 -1
- data/lib/json.rb +583 -196
- metadata +78 -137
- data/CHANGES +0 -25
- data/GPL +0 -340
- data/README +0 -77
- data/Rakefile +0 -250
- data/TODO +0 -1
- data/VERSION +0 -1
- data/benchmarks/benchmark.txt +0 -133
- data/benchmarks/benchmark_generator.rb +0 -44
- data/benchmarks/benchmark_parser.rb +0 -22
- data/benchmarks/benchmark_rails.rb +0 -26
- data/bin/edit_json.rb +0 -11
- data/data/example.json +0 -1
- data/data/index.html +0 -37
- data/data/prototype.js +0 -2515
- data/ext/json/ext/generator/Makefile +0 -149
- data/ext/json/ext/generator/unicode.c +0 -184
- data/ext/json/ext/generator/unicode.h +0 -40
- data/ext/json/ext/parser/Makefile +0 -149
- data/ext/json/ext/parser/unicode.c +0 -156
- data/ext/json/ext/parser/unicode.h +0 -44
- data/install.rb +0 -26
- data/lib/json/Array.xpm +0 -21
- data/lib/json/FalseClass.xpm +0 -21
- data/lib/json/Hash.xpm +0 -21
- data/lib/json/Key.xpm +0 -73
- data/lib/json/NilClass.xpm +0 -21
- data/lib/json/Numeric.xpm +0 -28
- data/lib/json/String.xpm +0 -96
- data/lib/json/TrueClass.xpm +0 -21
- data/lib/json/editor.rb +0 -1207
- data/lib/json/json.xpm +0 -1499
- data/tests/fixtures/fail1.json +0 -1
- data/tests/fixtures/fail10.json +0 -1
- data/tests/fixtures/fail11.json +0 -1
- data/tests/fixtures/fail12.json +0 -1
- data/tests/fixtures/fail13.json +0 -1
- data/tests/fixtures/fail14.json +0 -1
- data/tests/fixtures/fail15.json +0 -1
- data/tests/fixtures/fail16.json +0 -1
- data/tests/fixtures/fail17.json +0 -1
- data/tests/fixtures/fail19.json +0 -1
- data/tests/fixtures/fail2.json +0 -1
- data/tests/fixtures/fail20.json +0 -1
- data/tests/fixtures/fail21.json +0 -1
- data/tests/fixtures/fail22.json +0 -1
- data/tests/fixtures/fail23.json +0 -1
- data/tests/fixtures/fail24.json +0 -1
- data/tests/fixtures/fail25.json +0 -1
- data/tests/fixtures/fail26.json +0 -1
- data/tests/fixtures/fail27.json +0 -2
- data/tests/fixtures/fail28.json +0 -2
- data/tests/fixtures/fail3.json +0 -1
- data/tests/fixtures/fail4.json +0 -1
- data/tests/fixtures/fail5.json +0 -1
- data/tests/fixtures/fail6.json +0 -1
- data/tests/fixtures/fail7.json +0 -1
- data/tests/fixtures/fail8.json +0 -1
- data/tests/fixtures/fail9.json +0 -1
- data/tests/fixtures/pass1.json +0 -56
- data/tests/fixtures/pass18.json +0 -1
- data/tests/fixtures/pass2.json +0 -1
- data/tests/fixtures/pass3.json +0 -6
- data/tests/runner.rb +0 -24
- data/tests/test_json.rb +0 -235
- data/tests/test_json_addition.rb +0 -94
- data/tests/test_json_fixtures.rb +0 -30
- data/tests/test_json_generate.rb +0 -81
- data/tests/test_json_unicode.rb +0 -55
- data/tools/fuzz.rb +0 -133
- data/tools/server.rb +0 -62
data/Rakefile
DELETED
@@ -1,250 +0,0 @@
|
|
1
|
-
# vim: set et sw=2 ts=2:
|
2
|
-
require 'rake/gempackagetask'
|
3
|
-
require 'rake/clean'
|
4
|
-
|
5
|
-
require 'rbconfig'
|
6
|
-
include Config
|
7
|
-
|
8
|
-
PKG_NAME = 'json'
|
9
|
-
PKG_VERSION = File.read('VERSION').chomp
|
10
|
-
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|coverage/)
|
11
|
-
EXT_ROOT_DIR = 'ext/json/ext'
|
12
|
-
EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
|
13
|
-
EXT_PARSER_DL = "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}"
|
14
|
-
EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
|
15
|
-
PKG_FILES << EXT_PARSER_SRC
|
16
|
-
EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
|
17
|
-
EXT_GENERATOR_DL = "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
|
18
|
-
EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
|
19
|
-
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd].find { |c| system(c, '-v') }
|
20
|
-
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
|
21
|
-
CLEAN.include 'doc', 'coverage', FileList['diagrams/*.*'],
|
22
|
-
FileList["ext/**/*.{so,bundle,#{CONFIG['DLEXT']},o}"]
|
23
|
-
|
24
|
-
desc "Installing library (pure)"
|
25
|
-
task :install_pure => :version do
|
26
|
-
ruby 'install.rb'
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Installing library (extension)"
|
30
|
-
task :install_ext => [ :compile, :install_pure ] do
|
31
|
-
sitearchdir = CONFIG["sitearchdir"]
|
32
|
-
cd 'ext' do
|
33
|
-
for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
|
34
|
-
d = File.join(sitearchdir, file)
|
35
|
-
mkdir_p File.dirname(d)
|
36
|
-
install(file, d)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
task :install => :install_ext
|
42
|
-
|
43
|
-
desc "Compiling extension"
|
44
|
-
task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
|
45
|
-
|
46
|
-
file EXT_PARSER_DL => EXT_PARSER_SRC do
|
47
|
-
cd EXT_PARSER_DIR do
|
48
|
-
ruby 'extconf.rb'
|
49
|
-
sh 'make'
|
50
|
-
end
|
51
|
-
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
52
|
-
end
|
53
|
-
|
54
|
-
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
|
55
|
-
cd EXT_GENERATOR_DIR do
|
56
|
-
ruby 'extconf.rb'
|
57
|
-
sh 'make'
|
58
|
-
end
|
59
|
-
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
60
|
-
end
|
61
|
-
|
62
|
-
desc "Generate parser with ragel"
|
63
|
-
task :ragel => EXT_PARSER_SRC
|
64
|
-
|
65
|
-
task :ragel_clean do
|
66
|
-
rm_rf EXT_PARSER_SRC
|
67
|
-
end
|
68
|
-
|
69
|
-
file EXT_PARSER_SRC => RAGEL_PATH do
|
70
|
-
cd EXT_PARSER_DIR do
|
71
|
-
sh "ragel parser.rl | #{RAGEL_CODEGEN} -G2"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
desc "Generate diagrams of ragel parser (ps)"
|
76
|
-
task :ragel_dot_ps do
|
77
|
-
root = 'diagrams'
|
78
|
-
cd EXT_PARSER_DIR do
|
79
|
-
specs = []
|
80
|
-
File.new('parser.rl').grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
81
|
-
for s in specs
|
82
|
-
sh "ragel parser.rl -S#{s} | #{RAGEL_CODEGEN} -p -V|dot -Tps -o#{root}/#{s}.ps"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
desc "Generate diagrams of ragel parser (png)"
|
88
|
-
task :ragel_dot_png do
|
89
|
-
root = 'diagrams'
|
90
|
-
cd EXT_PARSER_DIR do
|
91
|
-
specs = []
|
92
|
-
File.new('parser.rl').grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
93
|
-
for s in specs
|
94
|
-
sh "ragel parser.rl -S#{s} | #{RAGEL_CODEGEN} -p -V|dot -Tpng -o#{root}/#{s}.png"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
desc "Generate diagrams of ragel parser"
|
100
|
-
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
|
101
|
-
|
102
|
-
desc "Testing library (pure ruby)"
|
103
|
-
task :test_pure => :clean do
|
104
|
-
ruby '-I lib tests/runner.rb'
|
105
|
-
end
|
106
|
-
|
107
|
-
desc "Testing library (extension)"
|
108
|
-
task :test_ext => :compile do
|
109
|
-
ruby '-I ext:lib tests/runner.rb'
|
110
|
-
end
|
111
|
-
|
112
|
-
desc "Benchmarking parser (pure)"
|
113
|
-
task :benchmark_parser_pure do
|
114
|
-
ruby '-I lib benchmarks/benchmark_parser.rb'
|
115
|
-
end
|
116
|
-
|
117
|
-
desc "Benchmarking generator (pure)"
|
118
|
-
task :benchmark_generator_pure do
|
119
|
-
ruby '-I lib benchmarks/benchmark_generator.rb'
|
120
|
-
ruby 'benchmarks/benchmark_rails.rb'
|
121
|
-
end
|
122
|
-
|
123
|
-
desc "Benchmarking library (pure)"
|
124
|
-
task :benchmark_pure => [ :benchmark_parser_pure, :benchmark_generator_pure ]
|
125
|
-
|
126
|
-
desc "Benchmarking parser (extension)"
|
127
|
-
task :benchmark_parser_ext => :compile do
|
128
|
-
ruby '-I ext:lib benchmarks/benchmark_parser.rb'
|
129
|
-
end
|
130
|
-
|
131
|
-
desc "Benchmarking generator (extension)"
|
132
|
-
task :benchmark_generator_ext => :compile do
|
133
|
-
ruby '-I ext:lib benchmarks/benchmark_generator.rb'
|
134
|
-
ruby 'benchmarks/benchmark_rails.rb'
|
135
|
-
end
|
136
|
-
|
137
|
-
desc "Benchmarking library (extension)"
|
138
|
-
task :benchmark_ext => [ :benchmark_parser_ext, :benchmark_generator_ext ]
|
139
|
-
|
140
|
-
task :benchmark do
|
141
|
-
puts "Benchmarking extension variant"
|
142
|
-
Rake::Task[:benchmark_ext].invoke
|
143
|
-
puts "Benchmarking pure variant"
|
144
|
-
Rake::Task[:benchmark_pure].invoke
|
145
|
-
end
|
146
|
-
|
147
|
-
desc "Testing library with coverage" # XXX broken
|
148
|
-
task :coverage do
|
149
|
-
system 'RUBYOPT="" rcov -x tests -Ilib tests/runner.rb'
|
150
|
-
end
|
151
|
-
|
152
|
-
desc "Create RDOC documentation"
|
153
|
-
task :doc => [ :version, EXT_PARSER_SRC ] do
|
154
|
-
sh "rdoc -m JSON -d -S -o doc #{FileList['lib/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
|
155
|
-
end
|
156
|
-
|
157
|
-
spec_pure = Gem::Specification.new do |s|
|
158
|
-
s.name = 'json_pure'
|
159
|
-
s.version = PKG_VERSION
|
160
|
-
s.summary = "A JSON implementation in Ruby"
|
161
|
-
s.description = ""
|
162
|
-
|
163
|
-
s.files = PKG_FILES
|
164
|
-
|
165
|
-
s.require_path = 'lib'
|
166
|
-
|
167
|
-
s.bindir = "bin"
|
168
|
-
s.executables = ["edit_json.rb"]
|
169
|
-
s.default_executable = "edit_json.rb"
|
170
|
-
|
171
|
-
s.has_rdoc = true
|
172
|
-
s.rdoc_options <<
|
173
|
-
'--title' << 'JSON -- A JSON implemention' <<
|
174
|
-
'--main' << 'JSON' << '--line-numbers'
|
175
|
-
s.test_files << 'tests/runner.rb'
|
176
|
-
|
177
|
-
s.author = "Florian Frank"
|
178
|
-
s.email = "flori@ping.de"
|
179
|
-
s.homepage = "http://json.rubyforge.org"
|
180
|
-
s.rubyforge_project = "json"
|
181
|
-
end
|
182
|
-
|
183
|
-
Rake::GemPackageTask.new(spec_pure) do |pkg|
|
184
|
-
pkg.need_tar = true
|
185
|
-
pkg.package_files += PKG_FILES
|
186
|
-
end
|
187
|
-
|
188
|
-
spec_ext = Gem::Specification.new do |s|
|
189
|
-
s.name = 'json'
|
190
|
-
s.version = PKG_VERSION
|
191
|
-
s.summary = "A JSON implementation as a Ruby extension"
|
192
|
-
s.description = ""
|
193
|
-
|
194
|
-
s.files = PKG_FILES
|
195
|
-
|
196
|
-
s.extensions <<
|
197
|
-
"#{EXT_PARSER_DIR}/extconf.rb" <<
|
198
|
-
"#{EXT_GENERATOR_DIR}/extconf.rb"
|
199
|
-
|
200
|
-
s.require_path = EXT_ROOT_DIR
|
201
|
-
s.require_paths << 'ext'
|
202
|
-
s.require_paths << 'lib'
|
203
|
-
|
204
|
-
s.bindir = "bin"
|
205
|
-
s.executables = ["edit_json.rb"]
|
206
|
-
s.default_executable = "edit_json.rb"
|
207
|
-
|
208
|
-
s.has_rdoc = true
|
209
|
-
s.rdoc_options <<
|
210
|
-
'--title' << 'JSON -- A JSON implemention' <<
|
211
|
-
'--main' << 'JSON' << '--line-numbers'
|
212
|
-
s.test_files << 'tests/runner.rb'
|
213
|
-
|
214
|
-
s.author = "Florian Frank"
|
215
|
-
s.email = "flori@ping.de"
|
216
|
-
s.homepage = "http://json.rubyforge.org"
|
217
|
-
s.rubyforge_project = "json"
|
218
|
-
end
|
219
|
-
|
220
|
-
Rake::GemPackageTask.new(spec_ext) do |pkg|
|
221
|
-
pkg.need_tar = true
|
222
|
-
pkg.package_files += PKG_FILES
|
223
|
-
end
|
224
|
-
|
225
|
-
task :mrproper => [ :ragel_clean, :clean ] do
|
226
|
-
for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ]
|
227
|
-
cd(dir) { rm_f 'Makefile' }
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
desc m = "Writing version information for #{PKG_VERSION}"
|
232
|
-
task :version do
|
233
|
-
puts m
|
234
|
-
File.open(File.join('lib', 'json', 'version.rb'), 'w') do |v|
|
235
|
-
v.puts <<EOT
|
236
|
-
module JSON
|
237
|
-
# JSON version
|
238
|
-
VERSION = '#{PKG_VERSION}'
|
239
|
-
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
240
|
-
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
241
|
-
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
242
|
-
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
243
|
-
end
|
244
|
-
EOT
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
task :release => [ :version, :clean, :ragel_clean, :ragel, :package ]
|
249
|
-
|
250
|
-
task :default => [ :version, :compile ]
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.0
|
data/benchmarks/benchmark.txt
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
(in /home/flori/json)
|
2
|
-
Ragel Code Generator version 5.17 January 2007
|
3
|
-
Copyright (c) 2001-2006 by Adrian Thurston
|
4
|
-
Benchmarking extension variant
|
5
|
-
First run for warmup.
|
6
|
-
Running 'BC_Parser' for a duration of 10 secs per method:
|
7
|
-
real total utime stime cutime cstime
|
8
|
-
parser: 10.005944 10.010000 9.970000 0.040000 0.000000 0.000000
|
9
|
-
5091 508.591409 0.001966
|
10
|
-
calls calls/sec secs/call
|
11
|
-
--------------------------------------------------------------------------------
|
12
|
-
Running 'BC_Parser' for a duration of 10 secs per method:
|
13
|
-
real total utime stime cutime cstime
|
14
|
-
parser: 10.006881 10.000000 9.950000 0.050000 0.000000 0.000000
|
15
|
-
5055 505.500000 0.001978
|
16
|
-
calls calls/sec secs/call
|
17
|
-
--------------------------------------------------------------------------------
|
18
|
-
================================================================================
|
19
|
-
|
20
|
-
|
21
|
-
[null,false,true,"f\u00d6\u00df\u00c4r",["n\u20acst\u20acd",true],{"quux":true,"foo\u00df":"b\u00e4r"}]
|
22
|
-
First run for warmup.
|
23
|
-
Running 'BC_Generator' for a duration of 10 secs per method:
|
24
|
-
real total utime stime cutime cstime
|
25
|
-
generator_pretty: 10.001066 10.010000 9.990000 0.020000 0.000000 0.000000
|
26
|
-
3492 348.851149 0.002867
|
27
|
-
generator_fast : 10.002910 10.000000 9.980000 0.020000 0.000000 0.000000
|
28
|
-
5416 541.600000 0.001846
|
29
|
-
generator_safe : 10.003107 10.010000 10.000000 0.010000 0.000000 0.000000
|
30
|
-
4926 492.107892 0.002032
|
31
|
-
calls calls/sec secs/call
|
32
|
-
--------------------------------------------------------------------------------
|
33
|
-
Running 'BC_Generator' for a duration of 10 secs per method:
|
34
|
-
real total utime stime cutime cstime
|
35
|
-
generator_pretty: 10.009150 10.010000 10.010000 0.000000 0.000000 0.000000
|
36
|
-
3511 350.749251 0.002851
|
37
|
-
generator_fast : 10.014407 10.020000 10.020000 0.000000 0.000000 0.000000
|
38
|
-
5411 540.019960 0.001852
|
39
|
-
generator_safe : 10.010055 10.000000 10.000000 0.000000 0.000000 0.000000
|
40
|
-
4933 493.300000 0.002027
|
41
|
-
calls calls/sec secs/call
|
42
|
-
--------------------------------------------------------------------------------
|
43
|
-
================================================================================
|
44
|
-
|
45
|
-
Comparison in BC_Generator:
|
46
|
-
secs/call speed
|
47
|
-
generator_fast : 0.002 -> 1.540x
|
48
|
-
generator_safe : 0.002 -> 1.406x
|
49
|
-
generator_pretty: 0.003 -> 1.000x
|
50
|
-
--------------------------------------------------------------------------------
|
51
|
-
|
52
|
-
[null, false, true, "f\u00d6\u00df\u00c4r", ["n\u20acst\u20acd", true], {quux: true, "foo\u00df": "b\u00e4r"}]
|
53
|
-
First run for warmup.
|
54
|
-
Running 'BC_Rails' for a duration of 10 secs per method:
|
55
|
-
real total utime stime cutime cstime
|
56
|
-
generator: 10.026043 10.020000 10.020000 0.000000 0.000000 0.000000
|
57
|
-
239 23.852295 0.041925
|
58
|
-
calls calls/sec secs/call
|
59
|
-
--------------------------------------------------------------------------------
|
60
|
-
Running 'BC_Rails' for a duration of 10 secs per method:
|
61
|
-
real total utime stime cutime cstime
|
62
|
-
generator: 10.010931 10.020000 10.010000 0.010000 0.000000 0.000000
|
63
|
-
238 23.752495 0.042101
|
64
|
-
calls calls/sec secs/call
|
65
|
-
--------------------------------------------------------------------------------
|
66
|
-
================================================================================
|
67
|
-
|
68
|
-
|
69
|
-
Benchmarking pure variant
|
70
|
-
First run for warmup.
|
71
|
-
Running 'BC_Parser' for a duration of 10 secs per method:
|
72
|
-
real total utime stime cutime cstime
|
73
|
-
parser: 10.022352 10.030000 10.020000 0.010000 0.000000 0.000000
|
74
|
-
288 28.713858 0.034826
|
75
|
-
calls calls/sec secs/call
|
76
|
-
--------------------------------------------------------------------------------
|
77
|
-
Running 'BC_Parser' for a duration of 10 secs per method:
|
78
|
-
real total utime stime cutime cstime
|
79
|
-
parser: 10.006552 10.000000 10.000000 0.000000 0.000000 0.000000
|
80
|
-
289 28.900000 0.034602
|
81
|
-
calls calls/sec secs/call
|
82
|
-
--------------------------------------------------------------------------------
|
83
|
-
================================================================================
|
84
|
-
|
85
|
-
|
86
|
-
[null,false,true,"f\u00d6\u00df\u00c4r",["n\u20acst\u20acd",true],{"quux":true,"foo\u00df":"b\u00e4r"}]
|
87
|
-
First run for warmup.
|
88
|
-
Running 'BC_Generator' for a duration of 10 secs per method:
|
89
|
-
real total utime stime cutime cstime
|
90
|
-
generator_fast : 10.011644 10.010000 10.010000 0.000000 0.000000 0.000000
|
91
|
-
411 41.058941 0.024355
|
92
|
-
generator_safe : 10.007100 10.010000 10.010000 0.000000 0.000000 0.000000
|
93
|
-
352 35.164835 0.028438
|
94
|
-
generator_pretty: 10.008156 10.010000 10.010000 0.000000 0.000000 0.000000
|
95
|
-
341 34.065934 0.029355
|
96
|
-
calls calls/sec secs/call
|
97
|
-
--------------------------------------------------------------------------------
|
98
|
-
Running 'BC_Generator' for a duration of 10 secs per method:
|
99
|
-
real total utime stime cutime cstime
|
100
|
-
generator_fast : 10.005185 10.010000 10.010000 0.000000 0.000000 0.000000
|
101
|
-
411 41.058941 0.024355
|
102
|
-
generator_safe : 10.006932 10.010000 10.010000 0.000000 0.000000 0.000000
|
103
|
-
351 35.064935 0.028519
|
104
|
-
generator_pretty: 10.007414 10.000000 10.000000 0.000000 0.000000 0.000000
|
105
|
-
340 34.000000 0.029412
|
106
|
-
calls calls/sec secs/call
|
107
|
-
--------------------------------------------------------------------------------
|
108
|
-
================================================================================
|
109
|
-
|
110
|
-
Comparison in BC_Generator:
|
111
|
-
secs/call speed
|
112
|
-
generator_fast : 0.024 -> 1.208x
|
113
|
-
generator_safe : 0.029 -> 1.031x
|
114
|
-
generator_pretty: 0.029 -> 1.000x
|
115
|
-
--------------------------------------------------------------------------------
|
116
|
-
|
117
|
-
[null, false, true, "f\u00d6\u00df\u00c4r", ["n\u20acst\u20acd", true], {quux: true, "foo\u00df": "b\u00e4r"}]
|
118
|
-
First run for warmup.
|
119
|
-
Running 'BC_Rails' for a duration of 10 secs per method:
|
120
|
-
real total utime stime cutime cstime
|
121
|
-
generator: 10.005748 10.000000 10.000000 0.000000 0.000000 0.000000
|
122
|
-
240 24.000000 0.041667
|
123
|
-
calls calls/sec secs/call
|
124
|
-
--------------------------------------------------------------------------------
|
125
|
-
Running 'BC_Rails' for a duration of 10 secs per method:
|
126
|
-
real total utime stime cutime cstime
|
127
|
-
generator: 10.006764 10.010000 10.010000 0.000000 0.000000 0.000000
|
128
|
-
239 23.876124 0.041883
|
129
|
-
calls calls/sec secs/call
|
130
|
-
--------------------------------------------------------------------------------
|
131
|
-
================================================================================
|
132
|
-
|
133
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bullshit'
|
4
|
-
$KCODE='utf8'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
class BC_Generator < Bullshit::TimeCase
|
8
|
-
include JSON
|
9
|
-
|
10
|
-
warmup true
|
11
|
-
duration 10
|
12
|
-
|
13
|
-
def setup
|
14
|
-
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
15
|
-
puts JSON[a]
|
16
|
-
@big = a * 100
|
17
|
-
end
|
18
|
-
|
19
|
-
def benchmark_generator_fast
|
20
|
-
@result = JSON.fast_generate(@big)
|
21
|
-
end
|
22
|
-
|
23
|
-
def reset_benchmark_generator_fast
|
24
|
-
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
def benchmark_generator_safe
|
28
|
-
@result = JSON.generate(@big)
|
29
|
-
end
|
30
|
-
|
31
|
-
def reset_benchmark_generator_safe
|
32
|
-
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
33
|
-
end
|
34
|
-
|
35
|
-
def benchmark_generator_pretty
|
36
|
-
@result = JSON.pretty_generate(@big)
|
37
|
-
end
|
38
|
-
|
39
|
-
def reset_benchmark_generator_pretty
|
40
|
-
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
41
|
-
end
|
42
|
-
|
43
|
-
compare :generator_fast, :generator_safe, :generator_pretty
|
44
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bullshit'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
class BC_Parser < Bullshit::TimeCase
|
7
|
-
include JSON
|
8
|
-
|
9
|
-
warmup true
|
10
|
-
duration 10
|
11
|
-
|
12
|
-
def setup
|
13
|
-
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
14
|
-
@big = a * 100
|
15
|
-
@json = JSON.generate(@big)
|
16
|
-
end
|
17
|
-
|
18
|
-
def benchmark_parser
|
19
|
-
a = JSON.parse(@json)
|
20
|
-
a == @big or raise "not equal"
|
21
|
-
end
|
22
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bullshit'
|
4
|
-
require 'active_support'
|
5
|
-
|
6
|
-
class BC_Rails < Bullshit::TimeCase
|
7
|
-
warmup true
|
8
|
-
duration 10
|
9
|
-
|
10
|
-
def setup
|
11
|
-
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
12
|
-
puts a.to_json
|
13
|
-
@big = a * 100
|
14
|
-
end
|
15
|
-
|
16
|
-
def benchmark_generator
|
17
|
-
@result = @big.to_json
|
18
|
-
end
|
19
|
-
|
20
|
-
def reset_benchmark_generator
|
21
|
-
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
22
|
-
if stack = Thread.current[:json_reference_stack]
|
23
|
-
stack.clear
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/bin/edit_json.rb
DELETED
data/data/example.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"a":2,"b":3.141,"TIME":"2007-03-14T11:52:40","c":"c","d":[1,"b",3.14],"COUNT":666,"e":{"foo":"bar"},"foo":"B\u00e4r","g":"\u677e\u672c\u884c\u5f18","h":1000.0,"bar":"\u00a9 \u2260 \u20ac!","i":0.001,"j":"\ud840\udc01"}
|
data/data/index.html
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
4
|
-
<head>
|
5
|
-
<title>Javascript Example</title>
|
6
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
7
|
-
<script src="prototype.js" type="text/javascript"></script>
|
8
|
-
</head>
|
9
|
-
|
10
|
-
<body>
|
11
|
-
<h1>Fetching object from server</h1>
|
12
|
-
<div id="list">
|
13
|
-
Switch on Javascript!
|
14
|
-
</div>
|
15
|
-
<script type="text/javascript">
|
16
|
-
<!--
|
17
|
-
function pollJSON() {
|
18
|
-
new Ajax.Request('/json',
|
19
|
-
{
|
20
|
-
method:'get',
|
21
|
-
onSuccess: function(transport){
|
22
|
-
var response = transport.responseText || "no response text";
|
23
|
-
response = eval("(" + response + ")");
|
24
|
-
var text = "";
|
25
|
-
for (var k in response) {
|
26
|
-
text = text + "<b>" + k + "</b>: " + response[k] + "<br/>"
|
27
|
-
}
|
28
|
-
$("list").update(text);
|
29
|
-
},
|
30
|
-
onFailure: function(){ alert('Something went wrong...') }
|
31
|
-
});
|
32
|
-
}
|
33
|
-
new PeriodicalExecuter(pollJSON, 1);
|
34
|
-
-->
|
35
|
-
</script>
|
36
|
-
</body>
|
37
|
-
</html>
|