json_pure 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/CHANGES +9 -0
  2. data/Rakefile +47 -53
  3. data/VERSION +1 -1
  4. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
  5. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
  6. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
  7. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
  8. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
  9. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
  10. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
  11. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
  12. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
  13. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
  14. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
  15. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
  16. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
  17. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
  18. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
  19. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
  20. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
  21. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
  22. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
  23. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
  24. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
  25. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
  26. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
  27. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
  28. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
  29. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
  30. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
  31. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
  32. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
  33. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
  34. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
  35. data/benchmarks/generator_benchmark.rb +162 -0
  36. data/benchmarks/parser_benchmark.rb +193 -0
  37. data/bin/edit_json.rb +0 -1
  38. data/bin/prettify_json.rb +0 -1
  39. data/doc-templates/main.txt +284 -0
  40. data/ext/json/ext/generator/extconf.rb +2 -0
  41. data/ext/json/ext/generator/generator.c +62 -18
  42. data/ext/json/ext/parser/extconf.rb +2 -0
  43. data/ext/json/ext/parser/parser.c +128 -81
  44. data/ext/json/ext/parser/parser.rl +31 -7
  45. data/ext/json/ext/parser/unicode.c +4 -4
  46. data/lib/json/add/core.rb +1 -1
  47. data/lib/json/editor.rb +11 -2
  48. data/lib/json/ext.rb +2 -0
  49. data/lib/json/pure/generator.rb +77 -41
  50. data/lib/json/pure/parser.rb +6 -2
  51. data/lib/json/pure.rb +2 -0
  52. data/lib/json/version.rb +1 -1
  53. data/lib/json.rb +0 -221
  54. data/tests/test_json.rb +7 -4
  55. data/tests/test_json_addition.rb +8 -5
  56. data/tests/test_json_fixtures.rb +6 -2
  57. data/tests/test_json_generate.rb +8 -2
  58. data/tests/test_json_rails.rb +30 -2
  59. data/tests/test_json_unicode.rb +8 -7
  60. data/tools/fuzz.rb +0 -1
  61. data/tools/server.rb +0 -1
  62. metadata +46 -9
  63. data/benchmarks/benchmark.txt +0 -133
  64. data/benchmarks/benchmark_generator.rb +0 -48
  65. data/benchmarks/benchmark_parser.rb +0 -26
  66. data/benchmarks/benchmark_rails.rb +0 -26
  67. data/tests/runner.rb +0 -25
@@ -1,11 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
1
4
  require 'test/unit'
2
- require 'json'
5
+ case ENV['JSON']
6
+ when 'pure' then require 'json/pure'
7
+ when 'ext' then require 'json/ext'
8
+ else require 'json'
9
+ end
3
10
 
4
11
  class TC_JSONGenerate < Test::Unit::TestCase
5
12
  include JSON
6
13
 
7
14
  def setup
8
- $KCODE = 'UTF8'
9
15
  @hash = {
10
16
  'a' => 2,
11
17
  'b' => 3.141,
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
2
3
 
3
4
  require 'test/unit'
5
+ case ENV['JSON']
6
+ when 'pure' then require 'json/pure'
7
+ when 'ext' then require 'json/ext'
8
+ else require 'json'
9
+ end
4
10
  require 'json/add/rails'
5
11
  require 'date'
6
12
 
@@ -50,17 +56,38 @@ class TC_JSONRails < Test::Unit::TestCase
50
56
  end
51
57
  end
52
58
 
53
- def setup
54
- $KCODE = 'UTF8'
59
+ class D
60
+ def initialize
61
+ @foo = 666
62
+ end
63
+
64
+ attr_reader :foo
65
+
66
+ def ==(other)
67
+ foo == other.foo
68
+ end
55
69
  end
56
70
 
57
71
  def test_extended_json
58
72
  a = A.new(666)
59
73
  assert A.json_creatable?
74
+ assert_equal 666, a.a
60
75
  json = generate(a)
61
76
  a_again = JSON.parse(json)
62
77
  assert_kind_of a.class, a_again
63
78
  assert_equal a, a_again
79
+ assert_equal 666, a_again.a
80
+ end
81
+
82
+ def test_extended_json_generic_object
83
+ d = D.new
84
+ assert D.json_creatable?
85
+ assert_equal 666, d.foo
86
+ json = generate(d)
87
+ d_again = JSON.parse(json)
88
+ assert_kind_of d.class, d_again
89
+ assert_equal d, d_again
90
+ assert_equal 666, d_again.foo
64
91
  end
65
92
 
66
93
  def test_extended_json_disabled
@@ -94,6 +121,7 @@ class TC_JSONRails < Test::Unit::TestCase
94
121
 
95
122
  def test_raw_strings
96
123
  raw = ''
124
+ raw.respond_to?(:encode!) and raw.encode!(Encoding::ASCII_8BIT)
97
125
  raw_array = []
98
126
  for i in 0..255
99
127
  raw << i
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
2
3
 
3
4
  require 'test/unit'
4
- require 'json'
5
+ case ENV['JSON']
6
+ when 'pure' then require 'json/pure'
7
+ when 'ext' then require 'json/ext'
8
+ else require 'json'
9
+ end
5
10
 
6
11
  class TC_JSONUnicode < Test::Unit::TestCase
7
12
  include JSON
8
13
 
9
- def setup
10
- $KCODE = 'UTF8'
11
- end
12
-
13
14
  def test_unicode
14
15
  assert_equal '""', ''.to_json
15
16
  assert_equal '"\\b"', "\b".to_json
@@ -53,8 +54,8 @@ class TC_JSONUnicode < Test::Unit::TestCase
53
54
  assert_equal json, JSON.generate(["" << i])
54
55
  end
55
56
  end
56
- assert_raises(JSON::GeneratorError) do
57
- JSON.generate(["" << 0x80])
57
+ assert_raise(JSON::GeneratorError) do
58
+ JSON.generate(["\x80"])
58
59
  end
59
60
  assert_equal "\302\200", JSON.parse('["\u0080"]').first
60
61
  end
data/tools/fuzz.rb CHANGED
@@ -1,4 +1,3 @@
1
- $KCODE='UTF8'
2
1
  require 'json'
3
2
 
4
3
  require 'iconv'
data/tools/server.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $KCODE='UTF8'
4
3
  require 'webrick'
5
4
  include WEBrick
6
5
  $:.unshift 'ext'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-11 00:00:00 +02:00
12
+ date: 2009-04-02 00:00:00 +02:00
13
13
  default_executable: edit_json.rb
14
14
  dependencies: []
15
15
 
@@ -101,17 +101,49 @@ files:
101
101
  - tests/fixtures/fail23.json
102
102
  - tests/fixtures/fail14.json
103
103
  - tests/fixtures/fail8.json
104
- - tests/runner.rb
105
104
  - tests/test_json_generate.rb
106
105
  - tests/test_json_rails.rb
107
106
  - tests/test_json_unicode.rb
108
107
  - tests/test_json_fixtures.rb
109
108
  - benchmarks
110
- - benchmarks/benchmark_parser.rb
111
- - benchmarks/benchmark_generator.rb
112
- - benchmarks/benchmark_rails.rb
113
- - benchmarks/benchmark.txt
109
+ - benchmarks/generator_benchmark.rb
110
+ - benchmarks/data-p4-3GHz-ruby18
111
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat
112
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat
113
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat
114
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat
115
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat
116
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat
117
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log
118
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat
119
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat
120
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat
121
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat
122
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log
123
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log
124
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log
125
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat
126
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log
127
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat
128
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat
129
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat
130
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat
131
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat
132
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat
133
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log
134
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log
135
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log
136
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat
137
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat
138
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log
139
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat
140
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat
141
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat
142
+ - benchmarks/data
143
+ - benchmarks/parser_benchmark.rb
114
144
  - Rakefile
145
+ - doc-templates
146
+ - doc-templates/main.txt
115
147
  - GPL
116
148
  - data
117
149
  - data/example.json
@@ -149,9 +181,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
181
  requirements: []
150
182
 
151
183
  rubyforge_project: json
152
- rubygems_version: 1.1.1
184
+ rubygems_version: 1.3.1
153
185
  signing_key:
154
186
  specification_version: 2
155
187
  summary: A JSON implementation in Ruby
156
188
  test_files:
157
- - tests/runner.rb
189
+ - tests/test_json.rb
190
+ - tests/test_json_addition.rb
191
+ - tests/test_json_generate.rb
192
+ - tests/test_json_rails.rb
193
+ - tests/test_json_unicode.rb
194
+ - tests/test_json_fixtures.rb
@@ -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,48 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bullshit'
4
- $KCODE='utf8'
5
- if ARGV.shift == 'pure'
6
- require 'json/pure'
7
- else
8
- require 'json/ext'
9
- end
10
-
11
- class BC_Generator < Bullshit::TimeCase
12
- include JSON
13
-
14
- warmup true
15
- duration 10
16
-
17
- def setup
18
- a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
19
- puts JSON[a]
20
- @big = a * 100
21
- end
22
-
23
- def benchmark_generator_fast
24
- @result = JSON.fast_generate(@big)
25
- end
26
-
27
- def reset_benchmark_generator_fast
28
- @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
29
- end
30
-
31
- def benchmark_generator_safe
32
- @result = JSON.generate(@big)
33
- end
34
-
35
- def reset_benchmark_generator_safe
36
- @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
37
- end
38
-
39
- def benchmark_generator_pretty
40
- @result = JSON.pretty_generate(@big)
41
- end
42
-
43
- def reset_benchmark_generator_pretty
44
- @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
45
- end
46
-
47
- compare :generator_fast, :generator_safe, :generator_pretty
48
- end
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bullshit'
4
- if ARGV.shift == 'pure'
5
- require 'json/pure'
6
- else
7
- require 'json/ext'
8
- end
9
-
10
- class BC_Parser < Bullshit::TimeCase
11
- include JSON
12
-
13
- warmup true
14
- duration 10
15
-
16
- def setup
17
- a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
18
- @big = a * 100
19
- @json = JSON.generate(@big)
20
- end
21
-
22
- def benchmark_parser
23
- a = JSON.parse(@json)
24
- a == @big or raise "not equal"
25
- end
26
- 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/tests/runner.rb DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit/ui/console/testrunner'
4
- require 'test/unit/testsuite'
5
- $:.unshift File.expand_path(File.dirname($0))
6
- $:.unshift 'tests'
7
- require 'test_json'
8
- require 'test_json_generate'
9
- require 'test_json_unicode'
10
- require 'test_json_addition'
11
- require 'test_json_rails'
12
- require 'test_json_fixtures'
13
-
14
- class TS_AllTests
15
- def self.suite
16
- suite = Test::Unit::TestSuite.new name
17
- suite << TC_JSONGenerate.suite
18
- suite << TC_JSON.suite
19
- suite << TC_JSONUnicode.suite
20
- suite << TC_JSONAddition.suite
21
- suite << TC_JSONRails.suite
22
- suite << TC_JSONFixtures.suite
23
- end
24
- end
25
- Test::Unit::UI::Console::TestRunner.run(TS_AllTests)