large messages for pipe/net, overridable duration
This commit is contained in:
parent
efb412f5b8
commit
aae4be7db5
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user