Closed ganmacs closed 2 years ago
Merging #465 (d96b036) into master (081dfc3) will increase coverage by
0.00%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #465 +/- ##
=======================================
Coverage 89.83% 89.84%
=======================================
Files 74 74
Lines 1555 1556 +1
=======================================
+ Hits 1397 1398 +1
Misses 158 158
Impacted Files | Coverage Δ | |
---|---|---|
lib/json-schema/validator.rb | 85.06% <100.00%> (+0.04%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 081dfc3...d96b036. Read the comment docs.
@ganmacs thanks for the PR. Could you rebase please to pull in our latest CI changes?
Thank you guys for your review. Rebased.
In my environment, I call
JSON::Validator.validate
many times with huge JSON Schema definitions and it takes a lot of time to return value. After some investigations, I found thatJSON::Validator#initialize_schema
inJSON::Validator#initialize
takes most of the time.This patch removes
@data
from instance variables of JSON::Validator so that it can avoid a lot of duplicated object creation. it's really useful and efficient when you want to apply the same schema but different data multiple time.flamegraph
code: https://gist.github.com/ganmacs/29f6217bbd3658d7f1f0010d0cadedd7 (json_schema_test.rb)
Before![Screen Shot 2022-02-16 at 14 23 11](https://user-images.githubusercontent.com/5616899/154201583-70a47fec-7db5-4ef1-8ba9-7eb3283706ad.png)
After![Screen Shot 2022-02-16 at 14 25 33](https://user-images.githubusercontent.com/5616899/154201695-ecbd587e-312f-4a24-b56a-925630cd7204.png)
benchmark
code: https://gist.github.com/ganmacs/29f6217bbd3658d7f1f0010d0cadedd7 (benchmark.rb)