diff options
Diffstat (limited to 'node_modules/webworker-threads/test/test10_node_nextTick_speed.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test10_node_nextTick_speed.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test10_node_nextTick_speed.js b/node_modules/webworker-threads/test/test10_node_nextTick_speed.js new file mode 100644 index 0000000..1a31fc7 --- /dev/null +++ b/node_modules/webworker-threads/test/test10_node_nextTick_speed.js @@ -0,0 +1,35 @@ + + +var Threads= require('webworker-threads'); + +function cb (err, msg) { + i++; + ƒ(); + //process.stdout.write('['+ this.id+ ']'); +} + + +function ƒ () { process.nextTick(cb) } + +var i= +process.argv[2] || 1; +console.log('Using '+ i+ ' threads'); + +var threads= []; +while (i--) { + ƒ(); +} + +i= 0; +var t= Date.now(); +function display () { + var e= Date.now()- t; + var tps= (i*1e3/e).toFixed(1); + process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps+ ', [ '+ threads.map(percent)+ ' ]'); + function percent (v) { + return Math.round(v/i*100); + } +} + + + +setInterval(display, 1e3);
\ No newline at end of file |
