Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Simple benchmark for node's startup time
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge authored and ry committed Sep 10, 2010
1 parent 9f6f260 commit 9b85772
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions benchmark/startup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var spawn = require('child_process').spawn,
path = require('path'),
emptyJsFile = path.join(__dirname, '../test/fixtures/empty.js'),
starts = 100,
i = 0,
start;

function startNode() {
var node = spawn(process.execPath || process.argv[0], [emptyJsFile]);
node.on('exit', function(exitCode) {
if (exitCode !== 0) {
throw new Error('Error during node startup');
}

i++;
if (i < starts) {
startNode();
} else{
var duration = +new Date - start;
console.log('Started node %d times in %s ms. %d ms / start.', starts, duration, duration / starts);
}
});
}

start = +new Date;
startNode();
1 change: 1 addition & 0 deletions test/fixtures/empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
;

0 comments on commit 9b85772

Please sign in to comment.