rc-web@69: /** rc-web@69: * Benchmark runner dependencies rc-web@69: */ rc-web@69: rc-web@69: var colors = require('colors') rc-web@69: , path = require('path'); rc-web@69: rc-web@69: /** rc-web@69: * Find all the benchmarks rc-web@69: */ rc-web@69: rc-web@69: var benchmarks_files = process.env.BENCHMARKS.split(' ') rc-web@69: , all = [].concat(benchmarks_files) rc-web@69: , first = all.shift() rc-web@69: , benchmarks = {}; rc-web@69: rc-web@69: // find the benchmarks and load them all in our obj rc-web@69: benchmarks_files.forEach(function (file) { rc-web@69: benchmarks[file] = require(path.join(__dirname, '..', file)); rc-web@69: }); rc-web@69: rc-web@69: // setup the complete listeners rc-web@69: benchmarks_files.forEach(function (file) { rc-web@69: var benchmark = benchmarks[file] rc-web@69: , next_file = all.shift() rc-web@69: , next = benchmarks[next_file]; rc-web@69: rc-web@69: /** rc-web@69: * Generate a oncomplete function for the tests, either we are done or we rc-web@69: * have more benchmarks to process. rc-web@69: */ rc-web@69: rc-web@69: function complete () { rc-web@69: if (!next) { rc-web@69: console.log( rc-web@69: '\n\nBenchmark completed in'.grey rc-web@69: , (Date.now() - start).toString().green + ' ms'.grey rc-web@69: ); rc-web@69: } else { rc-web@69: console.log('\nStarting benchmark '.grey + next_file.yellow); rc-web@69: next.run(); rc-web@69: } rc-web@69: } rc-web@69: rc-web@69: // attach the listener rc-web@69: benchmark.on('complete', complete); rc-web@69: }); rc-web@69: rc-web@69: /** rc-web@69: * Start the benchmark rc-web@69: */ rc-web@69: rc-web@69: var start = Date.now(); rc-web@69: console.log('Starting benchmark '.grey + first.yellow); rc-web@69: benchmarks[first].run();