dolos 0.2.0 → 0.3.0

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: 258d1d857ec1df4c70a50225e35114bbcc941b2901306d73db60543da1df93df
4
+ data.tar.gz: 3ec6f50215db6b4d719acc9552b5e6be34248452a7dcc4a6bef369e5e3c6ca2e
5
5
  SHA512:
6
- metadata.gz: 239dcd2a22ae2bcbd85e2915e28fe67eec4f0e75e9d7c7e4668ec930b30781cac256628833c8f5ca19cdafec1d31642098b27e5ba5a83c43e0abe08ae1277766
7
- data.tar.gz: 0c5698dd2cd7b91b9861125e6306ba99a7406bcaf4b1314eac5218fdc789235cc91d3794c67f0f82ff9cf32956b52f788e1c20607215f04586919a3988e75dad
6
+ metadata.gz: be62167ed5bd8b4bc57b5670434afc4b58789749f4306e70399416467160ba5f3a86a11adab7056d1b60ad72f96f3ed44e51fdc90601500a368e7ca7d99b7e19
7
+ data.tar.gz: 5e8f105222057ff27d9daafc2b2b5ec2e5e7b96ee7be84c665214b1d84e52fa0c87d126020a5606418b1a41002f69edbcbdf2d6bd514667c6b1317318c162373
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ AllCops:
2
+ DisabledByDefault: true
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Dolos
2
+ [![Gem version](https://badge.fury.io/rb/dolos.svg)](https://rubygems.org/gems/dolos)
3
+ [![Build status](https://github.com/benetis/dolos/actions/workflows/ruby.yml/badge.svg)](https://github.com/benetis/dolos/actions)
2
4
 
3
- <img height="256" src="docs/dolos_stable_diff.png" width="256"/>
5
+
6
+ <img height="256" src="docs/images/dolos_stable_diff.png" width="256"/>
4
7
 
5
8
 
6
9
  ### Disclaimer
@@ -40,13 +43,13 @@ require 'dolos_common_parsers/common_parsers'
40
43
  include Dolos
41
44
  # frozen_string_literal: true
42
45
  require_relative 'dolos'
43
- require_relative 'dolos_common_parsers/common_parsers'
46
+ require_relative 'dolos_parsers/common_parsers'
44
47
 
45
48
  include Dolos
46
49
 
47
50
  # Include common parsers
48
51
  # In future this can be more structured, moved them to separate module to prevent breaking changes
49
- include Dolos::CommonParsers
52
+ include Dolos::Common
50
53
 
51
54
  # Library usage example
52
55
  # Parse out a name and address from a letter
@@ -118,12 +121,21 @@ pp result.captures
118
121
  ### Benchmarks
119
122
  `bundle exec ruby benchmarks/json/json.rb`
120
123
  ```
121
- Calculating -------------------------------------
122
- nested json benchmark
123
- 0.090 (± 0.0%) i/s - 6.000 in 66.952366s
124
+ Dolos
125
+ nested json benchmark 8.426 (± 0.0%) i/s - 43.000 in 5.103600s
126
+ letter benchmark 3.145k (± 0.7%) i/s - 15.810k in 5.027961s
127
+
128
+ # Note: 23 times slower than Pure Ruby specialized json parser (below) if used to parse json
129
+ nested json 166KB bench 8.189 (± 0.0%) i/s - 41.000 in 5.007158s
130
+ nested json 1MB bench 0.959 (± 0.0%) i/s - 5.000 in 5.230650s
131
+
132
+ -----------------------------------------------------------
133
+ Pure ruby (flori/json)
134
+ nested json 1MB bench 24.213 (± 4.1%) i/s - 122.000 in 5.042309s
135
+ nested json 166KB bench 188.070 (± 1.6%) i/s - 954.000 in 5.073788s
136
+ Ruby native (C)
137
+ nested json 1MB bench 309.519 (± 0.3%) i/s - 1.560k in 5.040164s
124
138
  ```
125
- Its very slow, not ready for use yet. API is unstable is as well.
126
-
127
139
 
128
140
  ### Contributing
129
141
  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