Skip to content

Commit ea7750b

Browse files
yosuke-furukawabnoordhuis
authored andcommitted
benchmark: add filter option for benchmark
Before: # common.js executes all tests in net directory. $ ./iojs common.js net After: # common.js executes only "dgram" tests in net directory. $ ./iojs common.js net dgram PR-URL: #488 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 4764eef commit ea7750b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

benchmark/common.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ exports.PORT = process.env.PORT || 12346;
77
// If this is the main module, then run the benchmarks
88
if (module === require.main) {
99
var type = process.argv[2];
10+
var testFilter = process.argv[3];
1011
if (!type) {
11-
console.error('usage:\n ./iojs benchmark/common.js <type>');
12+
console.error('usage:\n ./iojs benchmark/common.js <type> [testFilter]');
1213
process.exit(1);
1314
}
1415

@@ -17,6 +18,19 @@ if (module === require.main) {
1718
var tests = fs.readdirSync(dir);
1819
var spawn = require('child_process').spawn;
1920

21+
if (testFilter) {
22+
var filteredTests = tests.filter(function(item){
23+
if (item.lastIndexOf(testFilter) >= 0) {
24+
return item;
25+
}
26+
});
27+
if (filteredTests.length === 0) {
28+
console.error(`${testFilter} is not found in \n ${tests.join(' \n')}`);
29+
return;
30+
}
31+
tests = filteredTests;
32+
}
33+
2034
runBenchmarks();
2135
}
2236

0 commit comments

Comments
 (0)