(table, localResults, remoteMasterResults)
| 41 | } |
| 42 | |
| 43 | function addBenchmarkResults(table, localResults, remoteMasterResults) { |
| 44 | const benchmarks = Object.keys( |
| 45 | (localResults && localResults.benchmarks) || |
| 46 | (remoteMasterResults && remoteMasterResults.benchmarks) |
| 47 | ); |
| 48 | benchmarks.forEach(benchmark => { |
| 49 | const rowHeader = [chalk.white.bold(benchmark)]; |
| 50 | if (remoteMasterResults) { |
| 51 | rowHeader.push(chalk.white.bold('Time')); |
| 52 | } |
| 53 | if (localResults) { |
| 54 | rowHeader.push(chalk.white.bold('Time')); |
| 55 | } |
| 56 | if (localResults && remoteMasterResults) { |
| 57 | rowHeader.push(chalk.white.bold('Diff')); |
| 58 | } |
| 59 | table.push(rowHeader); |
| 60 | |
| 61 | const measurements = |
| 62 | (localResults && localResults.benchmarks[benchmark].averages) || |
| 63 | (remoteMasterResults && |
| 64 | remoteMasterResults.benchmarks[benchmark].averages); |
| 65 | measurements.forEach((measurement, i) => { |
| 66 | const row = [chalk.gray(measurement.entry)]; |
| 67 | let remoteMean; |
| 68 | let remoteSem; |
| 69 | if (remoteMasterResults) { |
| 70 | remoteMean = remoteMasterResults.benchmarks[benchmark].averages[i].mean; |
| 71 | remoteSem = remoteMasterResults.benchmarks[benchmark].averages[i].sem; |
| 72 | // https://en.wikipedia.org/wiki/1.96 gives a 99% confidence interval. |
| 73 | const ci95 = remoteSem * 1.96; |
| 74 | row.push( |
| 75 | chalk.white(+remoteMean.toFixed(2) + ' ms +- ' + ci95.toFixed(2)) |
| 76 | ); |
| 77 | } |
| 78 | let localMean; |
| 79 | let localSem; |
| 80 | if (localResults) { |
| 81 | localMean = localResults.benchmarks[benchmark].averages[i].mean; |
| 82 | localSem = localResults.benchmarks[benchmark].averages[i].sem; |
| 83 | const ci95 = localSem * 1.96; |
| 84 | row.push( |
| 85 | chalk.white(+localMean.toFixed(2) + ' ms +- ' + ci95.toFixed(2)) |
| 86 | ); |
| 87 | } |
| 88 | if (localResults && remoteMasterResults) { |
| 89 | row.push(percentChange(remoteMean, localMean, remoteSem, localSem)); |
| 90 | } |
| 91 | table.push(row); |
| 92 | }); |
| 93 | }); |
| 94 | } |
| 95 | |
| 96 | function printResults(localResults, remoteMasterResults) { |
| 97 | const head = ['']; |
no test coverage detected