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
This is a micro performance optimisation which I don't generally condone - but in this case - every use of stableHash goes through those three lines before performing any other work. Therefore it's a hot spot in the code and I believe worthy of examination.
Of the work done on every call - these three lines are the expensive ones.
In my brief experimentation the performance gain is considerable when there is a cache hit (nearly 3x faster), and marginal when there is a miss (the other work performed on a miss includes calls to .sort and .toJson which will be very computationally expensive).
Happy do turn this into a pull request if you're in agreement with the change.
The text was updated successfully, but these errors were encountered:
Bug report
Description / Observed Behavior
I was looking through the codebase and specifically
src/_internal/utils/hash.ts
There are 3 calls to
isObjectType
which in turn executesOBJECT.prototype.toString.call(value)
.Expected Behavior
Given that
OBJECT.prototype.toString.call(value)
will be constant across these three calls the code could be changed to call thattoString
just once.Repro Steps / Code Example
becomes
Additional Context
This is a micro performance optimisation which I don't generally condone - but in this case - every use of
stableHash
goes through those three lines before performing any other work. Therefore it's a hot spot in the code and I believe worthy of examination.Of the work done on every call - these three lines are the expensive ones.
In my brief experimentation the performance gain is considerable when there is a cache hit (nearly 3x faster), and marginal when there is a miss (the other work performed on a miss includes calls to
.sort
and.toJson
which will be very computationally expensive).Happy do turn this into a pull request if you're in agreement with the change.
The text was updated successfully, but these errors were encountered: