Skip to content

Commit

Permalink
add new mode to latency test
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanczuk committed Apr 18, 2014
1 parent f4384fb commit 5234b68
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion performance/latency.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function help() {
console.log('Usage: node latency.js i|x <N>');
console.log(' i - in-process loop of N iterations');
console.log(' i - 1 compilation, in-process loop of N calls');
console.log(' c - in-process loop of N compilations and calls');
console.log(' x - child process loop of N iterations');
console.log('e.g. node latency.js i 1000');
process.exit(1);
Expand Down Expand Up @@ -38,6 +39,27 @@ if (process.argv[2] === 'i') {
});
}
}
if (process.argv[2] === 'c') {
var csharp = 'async (input) => { return ".NET welcomes " + input.ToString(); } /*';

var edge = require('../lib/edge');
var M = N;
var start = Date.now();
one_i();
function one_i() {
var code = csharp + M + '*/'; // force cache miss and recompile
var func = edge.func(code);
func('Node.js', function (error, result) {
if (error) throw error;
if (--M <= 0) {
var delta = Date.now() - start;
console.log(delta, delta / N);
}
else
setImmediate(one_i);
});
}
}
else if (process.argv[2] === 'x') {
var child_process = require('child_process');
var cmd = [process.argv[0], process.argv[1], 'i', '1'].join(' ');
Expand Down

0 comments on commit 5234b68

Please sign in to comment.