-
-
Save ganmacs/29f6217bbd3658d7f1f0010d0cadedd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json-schema' | |
require 'benchmark' | |
schema = YAML.load_file(File.open("rule.yml")).freeze | |
validator = JSON::Validator.new(schema) | |
body = .... | |
Benchmark.bm do |x| | |
x.report("before 100") { 100.times { JSON::Validator.validate(schema, data) } } | |
x.report("before 1000") { 1000.times { JSON::Validator.validate(schema, data) } } | |
x.report("before 5000") { 5000.times { JSON::Validator.validate(schema, data) } } | |
x.report("after 100") { 100.times { validator.validate(data) } } | |
x.report("after 1000") { 1000.times { validator.validate(data) } } | |
x.report("after 5000") { 5000.times { validator.validate(data) } } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json-schema' | |
require 'stackprof' | |
body = .... | |
schema = YAML.load_file(File.open("rule.yml")).freeze | |
StackProf.run(mode: :cpu, out: 'stackprof.dump', raw: true) do | |
100.times { JSON::Validator.validate(schema, body) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment