High performance limited replacement for setTimeout().
High performance but limited replacement for setTimeout().
It's about 5-20 times faster and requires 20 times less memory for handling timers (not including callback copies);
Compared to setTimeout() there are some drawbacks that make it limited for using:
npm install perf-timers
var PerfTimers = require'..';var timer = ;var now = Datenow;timersetTimeoutconsole.log'Delay' Datenow - now;1000;
var PerfTimers = require'..';varconsole.logids;;var timer = handler 1;for var i = 0; i < 10; i ++timersetTimeout'x' + i 10;
[ 'x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8', 'x9' ]
If you want to use more precise timers on short distances, use shorter interval
If you need timers running for hours it would be better to use longer interval (yes, timer accuracy will be minutewise):
new PerfTimers(60 * 1000);
A rule of thumb for best performance is to keep interval between
average timer / 1000 and
average timer / 3.