thoughtbot / json_matchers

Validate your JSON APIs
MIT License
384 stars 40 forks source link

Cache file reads #98

Open dizer opened 5 years ago

dizer commented 5 years ago

Now every match_json_schema call reloads the whole schema from disk. It may slow when there are many files (~1 second for each test example in our case).

This PR caches document store on the class level.

seanpdoyle commented 5 years ago

Could you provide more details in the commit message?

I'm very interested to learn more about the implications of these changes in your test suite, is that something that you've measured?

dizer commented 5 years ago

Hi @seanpdoyle

You can try benchmarks at https://github.com/dizer/json_matchers_cache

Original, single document, 1000 tries:
0.99 sec
Original, linked document, 1000 tries:
5.68 sec

Patched, single document, 1000 tries:
0.52 sec
Patched, linked document, 1000 tries:
0.92 sec

For our requests tests suite (124 JSON schema files, 5047 lines) it saved about a minute.

kzaitsev commented 3 years ago

Hi @seanpdoyle, any chance to get it merged? This feature is very helpful, with this patched version our specs working faster (3-4 minutes vs 20 minutes).

If you don't have time to resolve conflicts let me know, I'll create a new PR.

artofhuman commented 2 years ago

Hi @seanpdoyle. We also have same issues with speed in our tests after upgrade from 0.9 to 0.11 version. Could you merge this patch?

thai-eh commented 4 months ago

@seanpdoyle Please help take a look at this when you have a chance, thanks!