Skip to content

Commit

Permalink
benchmark: add filter option for benchmark
Browse files Browse the repository at this point in the history
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 <info@bnoordhuis.nl>
  • Loading branch information
yosuke-furukawa authored and bnoordhuis committed Jan 17, 2015
1 parent 4764eef commit ea7750b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ exports.PORT = process.env.PORT || 12346;
// 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 ./iojs benchmark/common.js <type>');
console.error('usage:\n ./iojs benchmark/common.js <type> [testFilter]');
process.exit(1);
}

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

if (testFilter) {
var filteredTests = tests.filter(function(item){
if (item.lastIndexOf(testFilter) >= 0) {
return item;
}
});
if (filteredTests.length === 0) {
console.error(`${testFilter} is not found in \n ${tests.join(' \n')}`);
return;
}
tests = filteredTests;
}

runBenchmarks();
}

Expand Down

0 comments on commit ea7750b

Please sign in to comment.