diff options
Diffstat (limited to 'node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js b/node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js new file mode 100644 index 0000000..8585ec8 --- /dev/null +++ b/node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js @@ -0,0 +1,32 @@ + + +var Threads= require('webworker-threads'); + +function cb (err, msg) { + i++; + this.eval(source, cb); + //process.stdout.write('['+ this.id+ ']'); +} + + +function ƒ () { } +var source= "ƒ()"; + +var i= +process.argv[2] || 1; +console.log('Using '+ i+ ' threads'); + + +while (i--) { + Threads.create().eval(ƒ).eval(source, cb); + process.stdout.write('.'); +} + +i= 0; +var t= Date.now(); +function display () { + var e= Date.now()- t; + var tps= (i*1e3/e).toFixed(1); + console.log('t (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps); +} + +setInterval(display, 1e3); |
