oj 0.9.0 → 1.0.0
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.
- data/README.md +95 -8
- data/ext/oj/fast.c +1540 -0
- data/ext/oj/load.c +1 -1
- data/ext/oj/oj.c +28 -21
- data/ext/oj/oj.h +6 -0
- data/lib/oj.rb +2 -1
- data/lib/oj/version.rb +1 -1
- data/test/perf_fast.rb +119 -0
- data/test/perf_strict.rb +13 -8
- data/test/test_fast.rb +331 -0
- data/test/where.rb +54 -0
- metadata +6 -2
data/test/where.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env ruby -wW1
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
|
|
4
|
+
$: << '.'
|
|
5
|
+
$: << File.join(File.dirname(__FILE__), "../lib")
|
|
6
|
+
$: << File.join(File.dirname(__FILE__), "../ext")
|
|
7
|
+
|
|
8
|
+
require 'optparse'
|
|
9
|
+
require 'perf'
|
|
10
|
+
require 'oj'
|
|
11
|
+
|
|
12
|
+
$verbose = false
|
|
13
|
+
$indent = 0
|
|
14
|
+
$iter = 1000000
|
|
15
|
+
|
|
16
|
+
opts = OptionParser.new
|
|
17
|
+
opts.on("-v", "verbose") { $verbose = true }
|
|
18
|
+
opts.on("-c", "--count [Int]", Integer, "iterations") { |i| $iter = i }
|
|
19
|
+
opts.on("-i", "--indent [Int]", Integer, "indentation") { |i| $indent = i }
|
|
20
|
+
opts.on("-h", "--help", "Show this display") { puts opts; Process.exit!(0) }
|
|
21
|
+
files = opts.parse(ARGV)
|
|
22
|
+
|
|
23
|
+
$obj = {
|
|
24
|
+
'a' => 'Alpha', # string
|
|
25
|
+
'b' => true, # boolean
|
|
26
|
+
'c' => 12345, # number
|
|
27
|
+
'd' => [ true, [false, [12345, nil], 3.967, ['something', false], nil]], # mix it up array
|
|
28
|
+
'e' => { 'one' => 1, 'two' => 2 }, # hash
|
|
29
|
+
'f' => nil, # nil
|
|
30
|
+
'g' => 12345678901234567890123456789, # big number
|
|
31
|
+
'h' => { 'a' => { 'b' => { 'c' => { 'd' => {'e' => { 'f' => { 'g' => nil }}}}}}}, # deep hash, not that deep
|
|
32
|
+
'i' => [[[[[[[nil]]]]]]] # deep array, again, not that deep
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Oj.default_options = { :indent => $indent, :mode => :strict }
|
|
36
|
+
|
|
37
|
+
$json = Oj.dump($obj)
|
|
38
|
+
|
|
39
|
+
if $verbose
|
|
40
|
+
puts "json:\n#{$json}\n"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
puts '-' * 80
|
|
44
|
+
puts "Parse Performance"
|
|
45
|
+
Oj::Fast.open($json) do |fast|
|
|
46
|
+
fast.move('/d/2/4/2')
|
|
47
|
+
puts fast.where2?
|
|
48
|
+
puts fast.where?
|
|
49
|
+
perf = Perf.new()
|
|
50
|
+
perf.add('Oj:fast', 'where') { fast.where? }
|
|
51
|
+
perf.add('Oj:fast2', 'where2') { fast.where2? }
|
|
52
|
+
perf.run($iter)
|
|
53
|
+
end
|
|
54
|
+
puts
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oj
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-03-
|
|
12
|
+
date: 2012-03-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: ! 'The fastest JSON parser and object serializer. '
|
|
15
15
|
email: peter@ohler.com
|
|
@@ -29,12 +29,14 @@ files:
|
|
|
29
29
|
- ext/oj/cache.c
|
|
30
30
|
- ext/oj/cache8.c
|
|
31
31
|
- ext/oj/dump.c
|
|
32
|
+
- ext/oj/fast.c
|
|
32
33
|
- ext/oj/load.c
|
|
33
34
|
- ext/oj/oj.c
|
|
34
35
|
- test/boo.rb
|
|
35
36
|
- test/files.rb
|
|
36
37
|
- test/foo.rb
|
|
37
38
|
- test/perf.rb
|
|
39
|
+
- test/perf_fast.rb
|
|
38
40
|
- test/perf_obj.rb
|
|
39
41
|
- test/perf_simple.rb
|
|
40
42
|
- test/perf_strict.rb
|
|
@@ -52,7 +54,9 @@ files:
|
|
|
52
54
|
- test/sample/text.rb
|
|
53
55
|
- test/sample.rb
|
|
54
56
|
- test/sample_json.rb
|
|
57
|
+
- test/test_fast.rb
|
|
55
58
|
- test/tests.rb
|
|
59
|
+
- test/where.rb
|
|
56
60
|
- LICENSE
|
|
57
61
|
- README.md
|
|
58
62
|
homepage: https://github.com/ohler55/oj
|