-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmark: move cli parts of common.js into run.js
It wasn't obviouse that common.js was the main cli tool. PR-URL: #7094 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
- Loading branch information
1 parent
edbed3f
commit 0f9bfaa
Showing
5 changed files
with
77 additions
and
69 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}); | ||
} |