-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* by default, run in fresh processes * optional run in same process
- Loading branch information
1 parent
7fac9d0
commit 2860a50
Showing
10 changed files
with
662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bower_components | ||
node_modules | ||
isolate-0x* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
### Running benchmarks | ||
|
||
note: these benchmarks run in seperate processes, the idea is to similate | ||
initial load + use, not after the JIT has settled | ||
|
||
```sh | ||
env NODE_ENV=production node runner.js ./benchmarks/scenarios/<name of scenario> | ||
``` | ||
|
||
If you want to run in a single process, to easily debug or run a profiler the | ||
`run-once.js` should be considered | ||
|
||
```sh | ||
env NODE_ENV=production node run-once.js ./benchmarks/scenarios/<name of scenario> | ||
``` | ||
|
||
Running with the profiler: | ||
|
||
```sh | ||
env NODE_ENV=production node --prof run-once.js ./benchmarks/scenarios/<name of scenario> | ||
|
||
# to view the output: | ||
node --prof-process isolate-0x<name of file> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var ps = require('child_process'); | ||
var series = require('promise-map-series'); | ||
var ora = require('ora'); | ||
var tests = []; | ||
var ara = require('ara'); | ||
var path = require('path'); | ||
var file = process.argv[2]; | ||
|
||
for (var i = 0; i < 50; i++) { | ||
tests.push({ | ||
id: i, | ||
run: function() { | ||
var worker = new ara.EvalWorker(); | ||
|
||
return worker.run(function(file) { | ||
return require(file)(); | ||
}, path.resolve(file)).finally(function() { | ||
worker.terminate(); | ||
}); | ||
}}); | ||
} | ||
|
||
var spinner = ora('running...'); | ||
|
||
console.log('Benchmark'); | ||
console.log(' file: ' + file); | ||
|
||
spinner.start(); | ||
|
||
series(tests, function(test) { | ||
spinner.text = 'running... (' + test.id+ '/' + tests.length + ')'; | ||
|
||
return test.run(); | ||
}).then(function(results) { | ||
spinner.stop(); | ||
|
||
var total = results.reduce(function(sum, result) { | ||
return sum + result.time; | ||
}, 0); | ||
|
||
console.log(' total: ', total + 'ms') | ||
console.log(' per op: ', total / results.length + 'ms'); | ||
}).catch(function(reason) { | ||
console.error(reason); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports.measure = function(cb) { | ||
var start; | ||
|
||
return new Promise(function(resolve) { | ||
start = Date.now(); | ||
var result = cb(); | ||
if (typeof result === 'object') { | ||
resolve(result); | ||
} else { | ||
resolve({ | ||
time: Date.now() - start | ||
}); | ||
} | ||
}).then(function() { | ||
return { | ||
time: Date.now() - start | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var file = process.argv[2]; | ||
var path = require('path'); | ||
|
||
require(path.resolve(process.argv[2]))().then(function(result) { | ||
console.log(result); | ||
}).catch(function(reason) { | ||
console.log(reason); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var ps = require('child_process'); | ||
var series = require('promise-map-series'); | ||
var ora = require('ora'); | ||
var tests = []; | ||
var ara = require('ara'); | ||
var path = require('path'); | ||
var file = process.argv[2]; | ||
|
||
for (var i = 0; i < 50; i++) { | ||
tests.push({ | ||
id: i, | ||
run: function() { | ||
var worker = new ara.EvalWorker(); | ||
|
||
return worker.run(function(file) { | ||
return require(file)(); | ||
}, path.resolve(file)).finally(function() { | ||
worker.terminate(); | ||
}); | ||
}}); | ||
} | ||
|
||
var spinner = ora('running...'); | ||
|
||
console.log('Benchmark'); | ||
console.log(' file: ' + file); | ||
|
||
spinner.start(); | ||
|
||
series(tests, function(test) { | ||
spinner.text = 'running... (' + test.id+ '/' + tests.length + ')'; | ||
|
||
return test.run(); | ||
}).then(function(results) { | ||
spinner.stop(); | ||
|
||
var total = results.reduce(function(sum, result) { | ||
return sum + result.time; | ||
}, 0); | ||
|
||
console.log(' total: ', total + 'ms') | ||
console.log(' per op: ', total / results.length + 'ms'); | ||
}).catch(function(reason) { | ||
console.error(reason); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var loader = require('../../lib/loader/loader.js'); | ||
var measure = require('../handler').measure; | ||
|
||
module.exports = function() { | ||
return measure(function() { | ||
loader.define('foo' + -1, function() {}); | ||
for (var i = 0; i < 1000; i++) { | ||
loader.define('foo' + i, ['foo' + (i - 1)], function() {}); | ||
} | ||
|
||
loader.require('foo' + (i - 1)); | ||
}); | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters