Summary
Right now, clock.timers in Lolex is an array, which is looped through completely everytime in firstTimer() or LastTimer().
This is extremely inefficient, and perhaps other data structures such as a heap might be much faster.
Background Details
Lolex is great for running simulations - but in one of my recent projects, I attempted to use Lolex to run a code over a simulated period of 1 week - the code made a LOT of setTimeouts, and these were all handled by Lolex.
Profiling the code showed the majority of my simulation runtime was spent in Lolex's firstTimer() function, because it kept looping through a long array of timers everytime.
Changing clock.timers to a simple heap fixed this performance bottleneck.
Since Lolex is targeted primarily towards running simulations/tests, being able to run them faster will be great.
Summary
Right now,
clock.timersin Lolex is an array, which is looped through completely everytime infirstTimer()orLastTimer().This is extremely inefficient, and perhaps other data structures such as a
heapmight be much faster.Background Details
Lolex is great for running simulations - but in one of my recent projects, I attempted to use Lolex to run a code over a simulated period of 1 week - the code made a LOT of
setTimeouts, and these were all handled by Lolex.Profiling the code showed the majority of my simulation runtime was spent in Lolex's
firstTimer()function, because it kept looping through a long array of timers everytime.Changing
clock.timersto a simple heap fixed this performance bottleneck.Since Lolex is targeted primarily towards running simulations/tests, being able to run them faster will be great.