diff options
author | Andreas Madsen <amwebdk@gmail.com> | 2016-01-30 14:27:02 +0100 |
---|---|---|
committer | Andreas Madsen <amwebdk@gmail.com> | 2016-07-26 12:48:46 +0200 |
commit | 0f9bfaa7c51bb5f4910ddf068ed89b1bdf35e7d5 (patch) | |
tree | 347e9dfe89313afe0eddab8361da0c697d256bd3 /benchmark/run.js | |
parent | edbed3f3fd8b0010f3f474934ad880fa2898265a (diff) | |
download | android-node-v8-0f9bfaa7c51bb5f4910ddf068ed89b1bdf35e7d5.tar.gz android-node-v8-0f9bfaa7c51bb5f4910ddf068ed89b1bdf35e7d5.tar.bz2 android-node-v8-0f9bfaa7c51bb5f4910ddf068ed89b1bdf35e7d5.zip |
benchmark: move cli parts of common.js into run.js
It wasn't obviouse that common.js was the main cli tool.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'benchmark/run.js')
-rw-r--r-- | benchmark/run.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/benchmark/run.js b/benchmark/run.js new file mode 100644 index 0000000000..ad590ea34a --- /dev/null +++ b/benchmark/run.js @@ -0,0 +1,63 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const child_process = require('child_process'); + +var outputFormat = process.env.OUTPUT_FORMAT || + (+process.env.NODE_BENCH_SILENT ? 'silent' : false) || + 'default'; + +// If this is the main module, then run the benchmarks +if (module === require.main) { + var type = process.argv[2]; + var testFilter = process.argv[3]; + if (!type) { + console.error('usage:\n ./node benchmark/run.js <type> [testFilter]'); + process.exit(1); + } + + var dir = path.join(__dirname, type); + var tests = fs.readdirSync(dir); + + if (testFilter) { + var filteredTests = tests.filter(function(item) { + if (item.lastIndexOf(testFilter) >= 0) { + return item; + } + }); + + if (filteredTests.length === 0) { + console.error('%s is not found in \n %j', testFilter, tests); + return; + } + tests = filteredTests; + } + + runBenchmarks(); +} + +function runBenchmarks() { + var test = tests.shift(); + if (!test) + return; + + if (test.match(/^[\._]/)) + return process.nextTick(runBenchmarks); + + if (outputFormat == 'default') + console.error(type + '/' + test); + + test = path.resolve(dir, test); + + var a = (process.execArgv || []).concat(test); + var child = child_process.spawn(process.execPath, a, { stdio: 'inherit' }); + child.on('close', function(code) { + if (code) { + process.exit(code); + } else { + console.log(''); + runBenchmarks(); + } + }); +} |