dolos 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdfe6ab9b41e2783d7a0f6fa530bccf44cecc1aaaf2dff900bc346ef980d8fef
4
- data.tar.gz: 29ee6fd6ff4bdc45a8d165a54e5a0a6bc57d3ae7068a60049d00385b37011fa7
3
+ metadata.gz: cfeffbbe4108e43ba81ccd210f2689910d310fc3947fe05ed22a9972e581e96a
4
+ data.tar.gz: e181ccca4725008464fc92670b8120cf55262ba469d6ec494270081eb902c241
5
5
  SHA512:
6
- metadata.gz: 239dcd2a22ae2bcbd85e2915e28fe67eec4f0e75e9d7c7e4668ec930b30781cac256628833c8f5ca19cdafec1d31642098b27e5ba5a83c43e0abe08ae1277766
7
- data.tar.gz: 0c5698dd2cd7b91b9861125e6306ba99a7406bcaf4b1314eac5218fdc789235cc91d3794c67f0f82ff9cf32956b52f788e1c20607215f04586919a3988e75dad
6
+ metadata.gz: 27fe73f34d41692d31c00d30bc03869cdefcef4ee785acbb72da12c9bceb85b78357da7c3d6d1435598b40fb635fb5e71d56254c18597c8d7d424748afc7c098
7
+ data.tar.gz: 9dd78f5e313830742505bbeb1488ed643a700facc2193ed3e996eef795913a50bb660a2af2dcd7c9a73e6e5f84befa7e461b2cf10d4bd11f22d68901ecc59e9b
data/README.md CHANGED
@@ -118,12 +118,21 @@ pp result.captures
118
118
  ### Benchmarks
119
119
  `bundle exec ruby benchmarks/json/json.rb`
120
120
  ```
121
- Calculating -------------------------------------
122
- nested json benchmark
123
- 0.090 (± 0.0%) i/s - 6.000 in 66.952366s
121
+ Dolos
122
+ nested json benchmark 8.426 (± 0.0%) i/s - 43.000 in 5.103600s
123
+ letter benchmark 3.145k (± 0.7%) i/s - 15.810k in 5.027961s
124
+
125
+ # Note: 23 times slower than Pure Ruby specialized json parser (below) if used to parse json
126
+ nested json 166KB bench 8.189 (± 0.0%) i/s - 41.000 in 5.007158s
127
+ nested json 1MB bench 0.959 (± 0.0%) i/s - 5.000 in 5.230650s
128
+
129
+ -----------------------------------------------------------
130
+ Pure ruby (flori/json)
131
+ nested json 1MB bench 24.213 (± 4.1%) i/s - 122.000 in 5.042309s
132
+ nested json 166KB bench 188.070 (± 1.6%) i/s - 954.000 in 5.073788s
133
+ Ruby native (C)
134
+ nested json 1MB bench 309.519 (± 0.3%) i/s - 1.560k in 5.040164s
124
135
  ```
125
- Its very slow, not ready for use yet. API is unstable is as well.
126
-
127
136
 
128
137
  ### Contributing
129
138
  Contributors are welcome. Note: since library is not yet stable, I recommend getting in touch with me before starting to work on something.
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'benchmark/ips'
4
+ require 'bundler/setup'
4
5
  require 'dolos'
5
6
  require 'dolos_common_parsers/common_parsers'
6
7
 
7
8
  include Dolos
8
9
  include Dolos::CommonParsers
9
-
10
- def ws_rep0 = ws.rep0
11
-
12
10
  def comma = c(",")
13
11
 
14
12
  def string_literal = (c("\"") >> char_while(->(ch) { ch != "\"" }).opt << c("\""))
@@ -47,14 +45,39 @@ end
47
45
 
48
46
  def json_parser = ws_rep0 >> value
49
47
 
50
- json_from_file = File.read('benchmarks/json/random.json')
48
+ require 'json/pure'
51
49
 
52
- Benchmark.ips do |x|
53
- x.time = 60
54
- x.warmup = 15
55
50
 
56
- x.report('nested json benchmark') do
51
+ json_from_file = File.read('benchmarks/json/nested_json_166.json')
52
+
53
+ result = json_parser.run(json_from_file)
54
+ puts result.success?
55
+
56
+ Benchmark.ips do |x|
57
+ x.report('nested json 166kb benchmark') do
57
58
  json_parser.run(json_from_file)
58
59
  end
60
+ x.report('Pure ruby json: nested json 166kb benchmark') do
61
+ JSON.parse(json_from_file)
62
+ end
63
+ x.compare!
64
+ end
65
+
66
+ json_from_file1m = File.read('benchmarks/json/nested_json_1m.json')
67
+ result1m = json_parser.run(json_from_file1m)
68
+ puts result1m.success?
69
+
70
+ # require 'json'
71
+
72
+ Benchmark.ips do |x|
73
+ # x.report('nested json 1mb benchmark') do
74
+ # json_parser.run(json_from_file1m)
75
+ # end
76
+ # x.report('Ruby native: nested json 1mb benchmark') do
77
+ # JSON.parse(json_from_file1m)
78
+ # end
79
+ # x.report('Pure ruby json: nested json 1mb benchmark') do
80
+ # JSON.parse(json_from_file1m)
81
+ # end
59
82
  x.compare!
60
83
  end