Closed dongelci closed 2 weeks ago
Hi, thanks for reporting. I will look into it.
There were two main inefficencies, I have a fix here https://github.com/lukas-krecan/JsonUnit/pull/783
Released as 3.3.0, let me know if it helped
Now request time is around 2s instead of 40-55s. I confirm significant improvement in wiremock
.
Thanks for fast reply and fix.
Hi,
This is a following issue wiremock/wiremock#2705, which I opened at
wiremock
since the issue is happening injson-unit
code.wiremock
is usingjson-unit
for a while comparing stubs with requests. We usewiremock
to stub external systems and have case-to-case big jsons in request body, which consists of similar keys in arrays. Sincewiremock
started usingjson-unit
, response times increased enormously, which cause tests to fail. Root cause of performance issue is happening at invocation ofdiff.similar()
. https://github.com/wiremock/wiremock/blob/2755c2fd5088d68a9d11426c71afbcc565c3913f/src/main/java/com/github/tomakehurst/wiremock/matching/EqualToJsonPattern.java#L96 I provided a unit test in forked project, which you can check. Jsons are anonymized.NormalisedNumberComparator
is added only to keep configuration same as inwiremock
. https://github.com/dongelci/JsonUnit/tree/gh-782 In unit test I am expectingdiff.similar()
method to finish in miliseconds level but needs nearly 7-8s. With configuration inwiremock
response time is around 10s. If we have 7 stubs (expecteds) inwiremock
, this time will be muliplied and request ends up with a response time over 40s. You can also checkmappingShouldResponseBeforeTimeoutBigJsonWithCommonKeys
test case inMappingsAcceptanceTest
. https://github.com/dongelci/wiremock/blob/71fff1c12b521f5af2e1d0cd74142a1bf0c5c309/src/test/java/com/github/tomakehurst/wiremock/MappingsAcceptanceTest.java#L250Questions:
wiremock
?Thanks