large messages for pipe/net, overridable duration

This commit is contained in:
Jean-Francois 2013-11-22 17:18:02 +01:00
parent efb412f5b8
commit aae4be7db5
2 changed files with 39 additions and 17 deletions

View File

@ -28,16 +28,26 @@ var perf = require("../perf/common-perf");
var net = require('net');
var body = 'hello world\n';
var PORT;
if (process.argv[2] === '-pipe') {
PORT = require("../../../../test/common.js").PIPE;
process.on('exit', function() {
require('fs').unlinkSync(PORT);
})
} else {
PORT = 9999;
var PORT = 9999;
var body = 'hello worldçoié\uD83D\uDC4D\n';
for(var arg in process.argv) {
switch(process.argv[arg]) {
case '-pipe': {
print("pipe");
PORT = require("../../../../test/common.js").PIPE;
process.on('exit', function() {
require('fs').unlinkSync(PORT);
})
break
}
case '-large': {
print('building large body...');
for (var i = 0; i < 1024 * 1024; i++) {
body += 'hello worldçoié\uD83D\uDC4D\n';
}
print('done building body');
}
}
}
var server = net.createServer(function(res) {

View File

@ -30,12 +30,22 @@ var memStart;
var log = console.log;
function startPerf(fstart, time) {
var duration = time ? time : 100
for(var arg in process.argv) {
switch(process.argv[arg]) {
case '-duration': {
var i = +arg + 1
duration = process.argv[i]
break
}
}
}
start = process.hrtime();
setTimeout(function() {
go = false;
}, time * 1000);
}, duration * 1000);
fstart();
log("Perf test started.");
log("Perf test started for " + duration + " seconds.");
}
exports.startPerf = startPerf;
function round(n) {
@ -89,11 +99,13 @@ function canContinue() {
function doExit() {
dumpResults();
log("Ending...");
forceGC();
var memEnd = captureMemory();
log("Memory after gc \n" + memToString(memEnd));
log("Heap Diff " + diffMemory(memStart, memEnd));
if (memStart) {
log("Ending...");
forceGC();
var memEnd = captureMemory();
log("Memory after gc \n" + memToString(memEnd));
log("Heap Diff " + diffMemory(memStart, memEnd));
}
process.exit(0);
}