summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js
blob: a40ccc2dc44ffb08d0a282c24f5b9415b98b2381 (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 i= 23; //8MB
var big= "*";
while (i--) big+= big;

console.log("big.length is "+ big.length);

var i= 0;
var s= Date.now();
var o= require('webworker-threads')
  .create()
  .eval(function boot () {
    thread.on('b', function (data) {
      thread.emit('a',data);
    });
  })
  .eval('boot()')
  .emit('b',big)
  .on('a', function (data) {
    o.emit('b',data);
    i+= 2;
  });


function display () {
  var e= Date.now()- s;
  var ppps= (i*1e3/e).toFixed(1);
  console.log("ping-pongs: "+ i+ ", ping-pongs-per-second: "+ ppps);
}

setInterval(display, 1e3);