diff options
Diffstat (limited to 'node_modules/webworker-threads/test/test00_run_once_and_destroy.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test00_run_once_and_destroy.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test00_run_once_and_destroy.js b/node_modules/webworker-threads/test/test00_run_once_and_destroy.js new file mode 100644 index 0000000..78eb895 --- /dev/null +++ b/node_modules/webworker-threads/test/test00_run_once_and_destroy.js @@ -0,0 +1,27 @@ + + +var Threads= require('webworker-threads'); + + +function cb (err, data) { + ++i; + console.log('['+ this.id+ '] -> '+ data); + this.destroy(); +} + +function ƒ () { return Math.random() } + +var i= +process.argv[2] || 1; +console.log('Using '+ i+ ' threads'); + +var t= Date.now(); +while (i--) { + Threads.create().eval(ƒ).eval('ƒ()', cb); +} + +i= 0; +process.on('exit', function () { + t= Date.now()- t; + console.log('THREADS PER SECOND -> '+ (i*1e3/t).toFixed(1)); + console.log('BYE !'); +}); |
