oj 3.13.2 → 3.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1280 -0
- data/README.md +1 -1
- data/RELEASE_NOTES.md +55 -0
- data/ext/oj/cache.c +240 -107
- data/ext/oj/cache.h +2 -1
- data/ext/oj/compat.c +1 -2
- data/ext/oj/custom.c +4 -7
- data/ext/oj/extconf.rb +1 -0
- data/ext/oj/intern.c +106 -216
- data/ext/oj/intern.h +0 -1
- data/ext/oj/mimic_json.c +2 -2
- data/ext/oj/object.c +10 -39
- data/ext/oj/oj.c +8 -5
- data/ext/oj/parser.c +167 -148
- data/ext/oj/saj2.c +3 -3
- data/ext/oj/strict.c +2 -3
- data/ext/oj/usual.c +55 -31
- data/ext/oj/wab.c +6 -3
- data/lib/oj/state.rb +8 -7
- data/lib/oj/version.rb +1 -1
- data/pages/Options.md +12 -2
- data/test/bar.rb +9 -28
- data/test/foo.rb +8 -8
- data/test/mem.rb +33 -0
- data/test/perf_once.rb +58 -0
- data/test/perf_parser.rb +6 -1
- data/test/test_parser_usual.rb +9 -5
- metadata +11 -2
data/test/foo.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
$: << File.dirname(__FILE__)
|
4
|
-
$oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
5
|
-
%w(lib ext).each do |dir|
|
6
|
-
$: << File.join($oj_dir, dir)
|
7
|
-
end
|
8
|
-
|
9
3
|
require 'oj'
|
10
4
|
|
11
|
-
|
5
|
+
Oj::default_options = {cache_str: 0, cache_keys: true, mode: :strict}
|
6
|
+
|
7
|
+
puts "Ruby version: #{RUBY_VERSION}"
|
8
|
+
puts "Oj version: #{Oj::VERSION}"
|
9
|
+
|
10
|
+
puts "cache_keys: #{Oj::default_options[:cache_keys]}"
|
11
|
+
puts "cache_str: #{Oj::default_options[:cache_str]}"
|
12
12
|
|
13
|
-
|
13
|
+
Oj.load('{"":""}').each_pair {|k,v| puts "k.frozen?: #{k.frozen?}\nv.frozen?: #{v.frozen?}"}
|
data/test/mem.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
$: << '.'
|
5
|
+
$: << File.join(File.dirname(__FILE__), "../lib")
|
6
|
+
$: << File.join(File.dirname(__FILE__), "../ext")
|
7
|
+
|
8
|
+
require 'oj'
|
9
|
+
|
10
|
+
Oj.default_options = { mode: :rails, cache_keys: false, cache_str: -1 }
|
11
|
+
|
12
|
+
def mem
|
13
|
+
`ps -o rss= -p #{$$}`.to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
('a'..'z').each { |a|
|
17
|
+
('a'..'z').each { |b|
|
18
|
+
('a'..'z').each { |c|
|
19
|
+
('a'..'z').each { |d|
|
20
|
+
('a'..'z').each { |e|
|
21
|
+
('a'..'z').each { |f|
|
22
|
+
key = "#{a}#{b}#{c}#{d}#{e}#{f}"
|
23
|
+
x = Oj.load(%|{ "#{key}": 101}|)
|
24
|
+
#Oj.dump(x)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
puts "#{a}#{b} #{mem}"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
Oj::Parser.new(:usual)
|
data/test/perf_once.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
$: << '.'
|
5
|
+
$: << File.join(File.dirname(__FILE__), "../lib")
|
6
|
+
$: << File.join(File.dirname(__FILE__), "../ext")
|
7
|
+
|
8
|
+
require 'oj'
|
9
|
+
|
10
|
+
filename = 'tmp.json'
|
11
|
+
File.open(filename, "w") { |f|
|
12
|
+
cnt = 0
|
13
|
+
f.puts('{')
|
14
|
+
('a'..'z').each { |a|
|
15
|
+
('a'..'z').each { |b|
|
16
|
+
('a'..'z').each { |c|
|
17
|
+
('a'..'z').each { |d|
|
18
|
+
f.puts(%|"#{a}#{b}#{c}#{d}":#{cnt},|)
|
19
|
+
cnt += 1
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
f.puts('"_last":0}')
|
25
|
+
}
|
26
|
+
|
27
|
+
def mem
|
28
|
+
`ps -o rss= -p #{$$}`.to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
Oj.default_options = { mode: :strict, cache_keys: false, cache_str: -1 }
|
32
|
+
start = Time.now
|
33
|
+
Oj.load_file('tmp.json')
|
34
|
+
dur = Time.now - start
|
35
|
+
GC.start
|
36
|
+
puts "no cache duration: #{dur} @ #{mem}"
|
37
|
+
|
38
|
+
Oj.default_options = { cache_keys: true }
|
39
|
+
start = Time.now
|
40
|
+
Oj.load_file('tmp.json')
|
41
|
+
dur = Time.now - start
|
42
|
+
GC.start
|
43
|
+
puts "initial cache duration: #{dur} @ #{mem}"
|
44
|
+
|
45
|
+
start = Time.now
|
46
|
+
Oj.load_file('tmp.json')
|
47
|
+
dur = Time.now - start
|
48
|
+
GC.start
|
49
|
+
puts "second cache duration: #{dur} @ #{mem}"
|
50
|
+
|
51
|
+
10.times{ GC.start }
|
52
|
+
start = Time.now
|
53
|
+
Oj.load_file('tmp.json')
|
54
|
+
dur = Time.now - start
|
55
|
+
GC.start
|
56
|
+
puts "after several GCs cache duration: #{dur} @ #{mem}"
|
57
|
+
|
58
|
+
# TBD check memory use
|
data/test/perf_parser.rb
CHANGED
@@ -53,7 +53,7 @@ Oj.default_options = {create_id: '^', create_additions: true, class_cache: true}
|
|
53
53
|
if $cache_keys
|
54
54
|
Oj.default_options = {cache_keys: true, cache_str: 6, symbol_keys: $symbol_keys}
|
55
55
|
else
|
56
|
-
Oj.default_options = {cache_keys: false, cache_str:
|
56
|
+
Oj.default_options = {cache_keys: false, cache_str: -1, symbol_keys: $symbol_keys}
|
57
57
|
end
|
58
58
|
JSON.parser = JSON::Ext::Parser
|
59
59
|
|
@@ -164,6 +164,11 @@ $obj_json = %|{
|
|
164
164
|
"juliet": "junk"
|
165
165
|
}|
|
166
166
|
|
167
|
+
|
168
|
+
p_usual = Oj::Parser.new(:usual)
|
169
|
+
p_usual.cache_keys = $cache_keys
|
170
|
+
p_usual.cache_strings = ($cache_keys ? 6 : 0)
|
171
|
+
p_usual.symbol_keys = $symbol_keys
|
167
172
|
p_usual.create_id = '^'
|
168
173
|
p_usual.class_cache = true
|
169
174
|
p_usual.ignore_json_create = true
|
data/test/test_parser_usual.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# encoding:
|
2
|
+
# encoding: utf-8
|
3
3
|
|
4
4
|
$: << File.dirname(__FILE__)
|
5
5
|
|
@@ -73,9 +73,14 @@ class UsualTest < Minitest::Test
|
|
73
73
|
assert_equal({a: true, b: false}, doc)
|
74
74
|
end
|
75
75
|
|
76
|
-
def
|
76
|
+
def test_strings
|
77
77
|
p = Oj::Parser.new(:usual)
|
78
|
-
p.
|
78
|
+
doc = p.parse('{"ぴ": "", "ぴ ": "x", "c": "ぴーたー", "d": " ぴーたー "}')
|
79
|
+
assert_equal({'ぴ' => '', 'ぴ ' => 'x', 'c' => 'ぴーたー', 'd' => ' ぴーたー '}, doc)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_capacity
|
83
|
+
p = Oj::Parser.new(:usual, capacity: 1000)
|
79
84
|
assert_equal(4096, p.capacity)
|
80
85
|
p.capacity = 5000
|
81
86
|
assert_equal(5000, p.capacity)
|
@@ -181,8 +186,7 @@ class UsualTest < Minitest::Test
|
|
181
186
|
end
|
182
187
|
|
183
188
|
def test_missing_class
|
184
|
-
p = Oj::Parser.new(:usual)
|
185
|
-
p.create_id = '^'
|
189
|
+
p = Oj::Parser.new(:usual, create_id: '^')
|
186
190
|
json = '{"a":true,"^":"Auto","b":false}'
|
187
191
|
doc = p.parse(json)
|
188
192
|
assert_equal(Hash, doc.class)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.13.
|
4
|
+
version: 3.13.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -79,6 +79,9 @@ extensions:
|
|
79
79
|
- ext/oj/extconf.rb
|
80
80
|
extra_rdoc_files:
|
81
81
|
- README.md
|
82
|
+
- LICENSE
|
83
|
+
- CHANGELOG.md
|
84
|
+
- RELEASE_NOTES.md
|
82
85
|
- pages/Advanced.md
|
83
86
|
- pages/Compatibility.md
|
84
87
|
- pages/Custom.md
|
@@ -91,8 +94,10 @@ extra_rdoc_files:
|
|
91
94
|
- pages/Security.md
|
92
95
|
- pages/WAB.md
|
93
96
|
files:
|
97
|
+
- CHANGELOG.md
|
94
98
|
- LICENSE
|
95
99
|
- README.md
|
100
|
+
- RELEASE_NOTES.md
|
96
101
|
- ext/oj/buf.h
|
97
102
|
- ext/oj/cache.c
|
98
103
|
- ext/oj/cache.h
|
@@ -218,11 +223,13 @@ files:
|
|
218
223
|
- test/json_gem/json_parser_test.rb
|
219
224
|
- test/json_gem/json_string_matching_test.rb
|
220
225
|
- test/json_gem/test_helper.rb
|
226
|
+
- test/mem.rb
|
221
227
|
- test/perf.rb
|
222
228
|
- test/perf_compat.rb
|
223
229
|
- test/perf_fast.rb
|
224
230
|
- test/perf_file.rb
|
225
231
|
- test/perf_object.rb
|
232
|
+
- test/perf_once.rb
|
226
233
|
- test/perf_parser.rb
|
227
234
|
- test/perf_saj.rb
|
228
235
|
- test/perf_scp.rb
|
@@ -347,11 +354,13 @@ test_files:
|
|
347
354
|
- test/json_gem/json_parser_test.rb
|
348
355
|
- test/json_gem/json_string_matching_test.rb
|
349
356
|
- test/json_gem/test_helper.rb
|
357
|
+
- test/mem.rb
|
350
358
|
- test/perf.rb
|
351
359
|
- test/perf_compat.rb
|
352
360
|
- test/perf_fast.rb
|
353
361
|
- test/perf_file.rb
|
354
362
|
- test/perf_object.rb
|
363
|
+
- test/perf_once.rb
|
355
364
|
- test/perf_parser.rb
|
356
365
|
- test/perf_saj.rb
|
357
366
|
- test/perf_scp.rb
|