Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / socket.io / benchmarks / runner.js
1 /**
2  * Benchmark runner dependencies
3  */
4
5 var colors = require('colors')
6   , path = require('path');
7
8 /**
9  * Find all the benchmarks
10  */
11
12 var benchmarks_files = process.env.BENCHMARKS.split(' ')
13   , all = [].concat(benchmarks_files)
14   , first = all.shift()
15   , benchmarks = {};
16
17 // find the benchmarks and load them all in our obj
18 benchmarks_files.forEach(function (file) {
19   benchmarks[file] = require(path.join(__dirname, '..', file));
20 });
21
22 // setup the complete listeners
23 benchmarks_files.forEach(function (file) {
24   var benchmark = benchmarks[file]
25     , next_file = all.shift()
26     , next = benchmarks[next_file];
27
28   /**
29    * Generate a oncomplete function for the tests, either we are done or we
30    * have more benchmarks to process.
31    */
32
33    function complete () {
34       if (!next) {
35         console.log(
36           '\n\nBenchmark completed in'.grey
37         , (Date.now() - start).toString().green + ' ms'.grey
38         );
39       } else {
40         console.log('\nStarting benchmark '.grey + next_file.yellow);
41         next.run();
42       }
43    }
44
45    // attach the listener
46    benchmark.on('complete', complete);
47 });
48
49 /**
50  * Start the benchmark
51  */
52
53 var start = Date.now();
54 console.log('Starting benchmark '.grey + first.yellow);
55 benchmarks[first].run();