W
W
wickedweasel2012-11-01 09:14:07
JavaScript
wickedweasel, 2012-11-01 09:14:07

Is clearTimeout slowing down for you too?

Comrades, I recently posted a pull request in node.js.
But one more interesting feature was discovered: on three different machines (running different Ubuntu), in addition to speeding up setTimeout by 5-50%, I get a 10-70 times speedup of clearTimeout (more precisely, setTimeout + clearTimeout bundles).

0.8.12; _ = null                    x    25 ops/sec ±4.13% (47 runs sampled)
0.9.3; _ = null                     x    17 ops/sec ±4.45% (49 runs sampled)
0.9.3 optimized; _ = null           x 1,042 ops/sec ±1.60% (97 runs sampled)

Please double-check this benchmark I wrote for me: github.com/AlexeyKupershtokh/timers-benchmark . And unsubscribe with results and information about OS versions, node.js, etc.
For those who do not risk running someone else's code:
wget https://raw.github.com/joyent/node/v0.8.12/lib/timers.js -O timers1.js
diff timers1.js timers_0.8.12.1.js
diff timers1.js timers_0.8.12.2.js
diff timers1.js timers_0.8.12.3.js
wget https://raw.github.com/joyent/node/v0.9.3/lib/timers.js -O timers2.js
diff timers2.js timers_0.9.3.1.js
diff timers2.js timers_0.9.3.2.js
diff timers2.js timers_0.9.3.3.js
diff timers2.js timers_my.1.js
diff timers2.js timers_my.2.js
diff timers2.js timers_my.3.js

+ github.com/AlexeyKupershtokh/timers-benchmark/blob...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
wickedweasel, 2012-11-01
@wickedweasel

If I use nodejs.org/dist/v0.9.3/node-v0.9.3-linux-x86.tar.gz , then on one machine (Ubuntu 11.04, Linux wicked-desktop 2.6.38-16-generic-pae #67 -Ubuntu SMP Thu Sep 6 18:18:02 UTC 2012 i686 i686 i386 GNU/Linux) I get these results:

[email protected]:~/timers-benchmark$ ../node-v0.9.3-linux-x86/bin/node run.js 
0.8.12; _ = null                    x  11 ops/sec ±7.61% (33 runs sampled)
0.9.3; _ = null                     x   8 ops/sec ±4.81% (25 runs sampled)
0.9.3 optimized; _ = null           x 621 ops/sec ±0.47% (94 runs sampled)

W
wickedweasel, 2012-11-01
@wickedweasel

on another machine in node 0.8.4 on windows vista 32 bit:

D:\work\node\timers-benchmark>node run.js
0.8.12; _ = null                    x    70 ops/sec +2.85% (66 runs sampled)
0.9.3; _ = null                     x    42 ops/sec +4.38% (57 runs sampled)
0.9.3 optimized; _ = null           x 1,247 ops/sec +3.62% (92 runs sampled)

- acceleration by 18-30 times.

W
wickedweasel, 2012-11-01
@wickedweasel

macbook with macos:

0.8.12; _ = null                    x    89 ops/sec ±2.49% (70 runs sampled)
0.9.3; _ = null                     x    60 ops/sec ±2.53% (65 runs sampled)
0.9.3 optimized; _ = null           x 2,287 ops/sec ±1.27% (95 runs sampled)

- acceleration by 25-38 times.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question