You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For this use-case, sorting isn't necessary at all since we're only interested in the property with minimal string distance. Instead, it could be determined in linear time in a single iteration.
The text was updated successfully, but these errors were encountered:
@schuay Looks related to the discussion in #1098. We always welcome performance improvements, but it's worth stressing that this isn't a critical codepath; it's only hit when someone writes a test with invalid Chai syntax (e.g., misspelling "true" in expect(myVar).to.be.ture).
Thanks for the pointer, indeed #1098 looks relevant. I think we can close this as a duplicate.
it's worth stressing that this isn't a critical codepath
Right, that's what it looked like. I wonder why the test suite / the web-tooling-benchmark stresses this path so much. As it stands, web-tooling-benchmark/chai is basically an Array-sort-with-a-crazy-expensive-comparison-function benchmark. cc @bmeurer
Found while investigating the web-tooling-benchmark:
We spend almost 1/3 of all time in the chai web-tooling-benchmark on sorting properties. The custom compare function is excessively expensive:
chai/chai.js
Line 9098 in 7db5214
For this use-case, sorting isn't necessary at all since we're only interested in the property with minimal string distance. Instead, it could be determined in linear time in a single iteration.
The text was updated successfully, but these errors were encountered: