diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-04-04 01:00:59 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-04-04 01:00:59 -0700 |
| commit | c7c22e3db1c826bcfb2bc66651ec480aae0d4ae0 (patch) | |
| tree | 8546df448afef40d3814d2581f4dacff7cebb87f /node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js | |
Diffstat (limited to 'node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js b/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js new file mode 100644 index 0000000..a40ccc2 --- /dev/null +++ b/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js @@ -0,0 +1,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); |
