summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webworker-threads/test/test03_infiniteLoopFunction.js')
-rw-r--r--node_modules/webworker-threads/test/test03_infiniteLoopFunction.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js b/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js
new file mode 100644
index 0000000..aca79c1
--- /dev/null
+++ b/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js
@@ -0,0 +1,32 @@
+
+
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ ++i;
+ process.stdout.write('['+ this.id+ ']['+ i+ '] -> '+ msg+ '\n');
+ //process.stdout.write('['+ this.id+ ']');
+}
+
+function ƒ () { while (1) {} }
+
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var threads= [];
+var t= Date.now();
+while (i--) {
+ Threads.create().eval(ƒ).eval('ƒ()', cb);
+}
+
+
+i= 0;
+(function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ console.log('\nTiempo total (ms) -> '+ e);
+ console.log('Threads por segundo -> '+ tps);
+ console.log('Total de threads ejecutadas -> '+ i);
+ setTimeout(display, 1e3);
+})();