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/test04_gc_versus_not_gc.js | |
Diffstat (limited to 'node_modules/webworker-threads/test/test04_gc_versus_not_gc.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test04_gc_versus_not_gc.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test04_gc_versus_not_gc.js b/node_modules/webworker-threads/test/test04_gc_versus_not_gc.js new file mode 100644 index 0000000..af745eb --- /dev/null +++ b/node_modules/webworker-threads/test/test04_gc_versus_not_gc.js @@ -0,0 +1,44 @@ + + +var Threads= require('webworker-threads'); + +console.log('Launch with/without --expose_gc to compare memory usage') + +function cb (err, msg) { + i++; + if (msg) console.log('['+ this.id+ ']'+ msg); + this.eval(source, cb); + //process.stdout.write('['+ this.id+ ']['+ i+ '] -> '+ msg+ '\n'); + //process.stdout.write('['+ this.id+ ']'); +} + + +function ƒ () { + if (++i % 10e3) return ''; + try { + gc(); + return ' -> gc()' + } + catch (e) { + return ' -> *NOT* gc()]'; + } +} +var source= "ƒ()"; + +var i= +process.argv[2] || 1; +console.log('Using '+ i+ ' threads'); + + +while (i--) { + Threads.create().eval(ƒ+ '\nvar i= 0;').eval(source, cb); +} + +i= 0; +var t= Date.now(); +function display () { + var e= Date.now()- t; + var tps= (i*1e3/e).toFixed(1); + console.log('t (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps); +} + +setInterval(display, 1e3); |
