blob: 1a31fc7c9886c40a55a7a9344d521c31d68e1e8b (
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
33
34
35
|
var Threads= require('webworker-threads');
function cb (err, msg) {
i++;
ƒ();
//process.stdout.write('['+ this.id+ ']');
}
function ƒ () { process.nextTick(cb) }
var i= +process.argv[2] || 1;
console.log('Using '+ i+ ' threads');
var threads= [];
while (i--) {
ƒ();
}
i= 0;
var t= Date.now();
function display () {
var e= Date.now()- t;
var tps= (i*1e3/e).toFixed(1);
process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps+ ', [ '+ threads.map(percent)+ ' ]');
function percent (v) {
return Math.round(v/i*100);
}
}
setInterval(display, 1e3);
|