aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/benchmarks/runner.js
blob: 81e55cae438117ee9f06d7278418eb1200124d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * Benchmark runner dependencies
 */

var colors = require('colors')
  , path = require('path');

/**
 * Find all the benchmarks
 */

var benchmarks_files = process.env.BENCHMARKS.split(' ')
  , all = [].concat(benchmarks_files)
  , first = all.shift()
  , benchmarks = {};

// find the benchmarks and load them all in our obj
benchmarks_files.forEach(function (file) {
  benchmarks[file] = require(path.join(__dirname, '..', file));
});

// setup the complete listeners
benchmarks_files.forEach(function (file) {
  var benchmark = benchmarks[file]
    , next_file = all.shift()
    , next = benchmarks[next_file];

  /**
   * Generate a oncomplete function for the tests, either we are done or we
   * have more benchmarks to process.
   */

   function complete () {
      if (!next) {
        console.log(
          '\n\nBenchmark completed in'.grey
        , (Date.now() - start).toString().green + ' ms'.grey
        );
      } else {
        console.log('\nStarting benchmark '.grey + next_file.yellow);
        next.run();
      }
   }

   // attach the listener
   benchmark.on('complete', complete);
});

/**
 * Start the benchmark
 */

var start = Date.now();
console.log('Starting benchmark '.grey + first.yellow);
benchmarks[first].run();