Open medikoo opened 9 years ago
As far as i remember, perf problem also can happen on thousands of setTimeout()
. Solution is to have a list of deadlines, and scan it with single timer.
@puzrin true, it's a great tip
For setTimeout it's possible to use the same function if you pass params:
.setTimeout(fn, delay, param1, param2, ...)
In browser that will require patch for IE <= 9 https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout
For setTimeout it's possible to use the same function if you pass params:
I'm not convinced it'll bring anything noticeable in terms of performance. I'm sure it's more important to produce less setTimeout
calls (decide on some threshold) as you suggested before
https://github.com/nodejs/node/blob/master/lib/timers.js#L283 there are unofficial enroll/unenroll functions. Can be used instead of setTimeout/clearTimeout. But i'm not sure this hack is really needed.
Currently for each memoized function there are few functions created, that affects memory badly when our configration deals with thousands of memoized instances. It'll be much more optimal to rely on prototype inheritance model in that case