summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/test/test05_debugLeaksNoCallbacks.js
blob: ec006ece35d90b3f885c4fe47c2c4a06e329caa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var Threads= require('webworker-threads');

function ƒ () { return Math.random() }

var  i= +process.argv[2] || 1;
console.log('Using '+ i+ ' threads');

var threads= [];
var t= Date.now();
while (i--) {
  var thread= Threads.create().eval(ƒ);
  threads.push(thread);
}

i= 0;
(function loop () {
  threads.forEach(function (v) {
    i++;
    v.eval('ƒ()');
  });
  process.nextTick(loop); //segfaults
})();


(function display () {
  var e= Date.now()- t;
  var tps= (i*1e3/e).toFixed(1);
  console.log('t (ms) -> '+ e+ ', tps -> '+ tps+ ', i -> '+ i);
  setTimeout(display, 1e3);
})();