diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-04-04 01:00:59 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-04-04 01:00:59 -0700 |
| commit | c7c22e3db1c826bcfb2bc66651ec480aae0d4ae0 (patch) | |
| tree | 8546df448afef40d3814d2581f4dacff7cebb87f /node_modules/webworker-threads/test/test13_thread_nextTick_speed.js | |
Diffstat (limited to 'node_modules/webworker-threads/test/test13_thread_nextTick_speed.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test13_thread_nextTick_speed.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test13_thread_nextTick_speed.js b/node_modules/webworker-threads/test/test13_thread_nextTick_speed.js new file mode 100644 index 0000000..58e0e25 --- /dev/null +++ b/node_modules/webworker-threads/test/test13_thread_nextTick_speed.js @@ -0,0 +1,31 @@ + + +var Threads= require('webworker-threads'); + +function ƒ () { + var i= 0; + var t= Date.now(); + + (function ƒ () { + thread.nextTick(ƒ); + + if ((++i % 1e6) === 0) { + var e= Date.now()- t; + var cps= (i*1e3/e).toFixed(1); + thread.emit("data", cps); + } + })(); + +} + +function onData (data) { + console.log(data); +} + +var i= +process.argv[2] || 1; +console.log('Using '+ i+ ' threads'); + +while (i--) { + Threads.create().on('data', onData).eval(ƒ).eval('ƒ()'); + process.stdout.write('.'); +} |
