Skip to content

Commit 5350f40

Browse files
committed
Use bunder/inline for benchmark
This way the dependencies don't need to be in the gemspec.
1 parent 2064b6d commit 5350f40

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

json_schemer.gemspec

-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ Gem::Specification.new do |spec|
2626
spec.add_development_dependency "rake", "~> 13.0"
2727
spec.add_development_dependency "minitest", "~> 5.0"
2828

29-
# spec.add_development_dependency "benchmark-ips", "~> 2.7.2"
30-
# spec.add_development_dependency "jschema", "~> 0.2.1"
31-
# spec.add_development_dependency "json-schema", "~> 2.8.0"
32-
# spec.add_development_dependency "json_schema", "~> 0.17.0"
33-
# spec.add_development_dependency "json_validation", "~> 0.1.0"
34-
# spec.add_development_dependency "jsonschema", "~> 2.0.2"
35-
# spec.add_development_dependency "rj_schema", "~> 0.2.0"
36-
3729
spec.add_runtime_dependency "ecma-re-validator", "~> 0.3"
3830
spec.add_runtime_dependency "hana", "~> 1.3"
3931
spec.add_runtime_dependency "regexp_parser", "~> 2.0"

test/benchmark.rb

+28-19
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# frozen_string_literal: true
2-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2+
require 'bundler/inline'
33

4-
require 'benchmark/ips'
5-
require 'jschema'
6-
require 'json-schema'
7-
require 'json_schema'
8-
require 'json_schemer'
9-
require 'json_validation'
10-
require 'rj_schema'
11-
# require 'jsonschema'
4+
require 'digest' # json_validation
125

13-
# json_validation
14-
require 'digest'
6+
Fixnum = Integer # jsonschema
7+
8+
gemfile do
9+
source 'https://rubygems.org'
10+
11+
gem 'benchmark-ips'
12+
gem 'webrick'
13+
gem 'jschema'
14+
gem 'json-schema'
15+
gem 'json_schema'
16+
gem 'json_validation'
17+
# gem 'jsonschema'
18+
gem 'rj_schema'
19+
20+
gem 'json_schemer', :path => '../'
21+
end
1522

1623
benchmarks = {
1724
'simple' => {
@@ -80,12 +87,14 @@
8087

8188
# json-schema
8289

83-
x.report("json-schema, #{name}, valid") do
84-
raise unless JSON::Validator.validate(schema, valid)
90+
x.report("json-schema, uninitialized, #{name}, valid") do
91+
errors = JSON::Validator.fully_validate(schema, valid)
92+
raise if errors.any?
8593
end
8694

87-
x.report("json-schema, #{name}, invalid") do
88-
raise if JSON::Validator.validate(schema, invalid)
95+
x.report("json-schema, uninitialized, #{name}, invalid") do
96+
errors = JSON::Validator.fully_validate(schema, invalid)
97+
raise if errors.empty?
8998
end
9099

91100
# json_schema
@@ -154,22 +163,22 @@
154163

155164
x.report("rj_schema, uninitialized, #{name}, valid") do
156165
errors = RjSchema::Validator.new.validate(schema, valid)
157-
raise if errors.any?
166+
raise if errors.fetch(:machine_errors).any?
158167
end
159168

160169
x.report("rj_schema, uninitialized, #{name}, invalid") do
161170
errors = RjSchema::Validator.new.validate(schema, invalid)
162-
raise if errors.empty?
171+
raise if errors.fetch(:machine_errors).empty?
163172
end
164173

165174
x.report("rj_schema, initialized, #{name}, valid") do
166175
errors = initialized_rj_schema.validate(:"schema", valid)
167-
raise if errors.any?
176+
raise if errors.fetch(:machine_errors).any?
168177
end
169178

170179
x.report("rj_schema, initialized, #{name}, invalid") do
171180
errors = initialized_rj_schema.validate(:"schema", invalid)
172-
raise if errors.empty?
181+
raise if errors.fetch(:machine_errors).empty?
173182
end
174183

175184
# jsonschema

0 commit comments

Comments
 (0)