|
1 | 1 | # frozen_string_literal: true
|
2 |
| -$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) |
| 2 | +require 'bundler/inline' |
3 | 3 |
|
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 |
12 | 5 |
|
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 |
15 | 22 |
|
16 | 23 | benchmarks = {
|
17 | 24 | 'simple' => {
|
|
80 | 87 |
|
81 | 88 | # json-schema
|
82 | 89 |
|
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? |
85 | 93 | end
|
86 | 94 |
|
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? |
89 | 98 | end
|
90 | 99 |
|
91 | 100 | # json_schema
|
|
154 | 163 |
|
155 | 164 | x.report("rj_schema, uninitialized, #{name}, valid") do
|
156 | 165 | errors = RjSchema::Validator.new.validate(schema, valid)
|
157 |
| - raise if errors.any? |
| 166 | + raise if errors.fetch(:machine_errors).any? |
158 | 167 | end
|
159 | 168 |
|
160 | 169 | x.report("rj_schema, uninitialized, #{name}, invalid") do
|
161 | 170 | errors = RjSchema::Validator.new.validate(schema, invalid)
|
162 |
| - raise if errors.empty? |
| 171 | + raise if errors.fetch(:machine_errors).empty? |
163 | 172 | end
|
164 | 173 |
|
165 | 174 | x.report("rj_schema, initialized, #{name}, valid") do
|
166 | 175 | errors = initialized_rj_schema.validate(:"schema", valid)
|
167 |
| - raise if errors.any? |
| 176 | + raise if errors.fetch(:machine_errors).any? |
168 | 177 | end
|
169 | 178 |
|
170 | 179 | x.report("rj_schema, initialized, #{name}, invalid") do
|
171 | 180 | errors = initialized_rj_schema.validate(:"schema", invalid)
|
172 |
| - raise if errors.empty? |
| 181 | + raise if errors.fetch(:machine_errors).empty? |
173 | 182 | end
|
174 | 183 |
|
175 | 184 | # jsonschema
|
|
0 commit comments