Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

http_simple benchmark: add --garbage option to benchmark with large h…

…eap sizes
  • Loading branch information...
piscisaureus committed May 4, 2012
1 parent 375b41c commit e72420a484f67c78f40f929a60c5e8c284f8b4a1
Showing with 30 additions and 0 deletions.
  1. +30 −0 benchmark/http_simple.js
@@ -6,6 +6,36 @@ port = parseInt(process.env.PORT || 8000);

console.log('pid ' + process.pid);

/* Usage: node http_simple.js [--garbage=<amount> [k|m|g] ] */
if (process.argv[2]) {
var result = process.argv[2].match(/^\s*--garbage=(\d+)(k|K|m|M|g|G|)\s*$/);
if (result) {
var bytes = +result[1];
switch ((result[2] || '').toLowerCase()) {
case 'k':
bytes <<= 10;
break;
case 'm':
bytes <<= 20;
break;
case 'g':
bytes <<= 30;
break;
}

console.log("Generating approximately " + bytes + " bytes of garbage");

var garbage = [];
var garbage_creation_buffer = new Buffer(65536);
garbage_creation_buffer.fill(32);
while (process.memoryUsage().heapUsed < bytes) {
garbage.push(garbage_creation_buffer.toString('ascii'));
}

console.log("Memory usage:", process.memoryUsage());
}
}

fixed = ""
for (var i = 0; i < 20*1024; i++) {
fixed += "C";

0 comments on commit e72420a

Please sign in to comment.
You can’t perform that action at this time.