(prev, current, prevSem, currentSem)
| 4 | const Table = require('cli-table'); |
| 5 | |
| 6 | function percentChange(prev, current, prevSem, currentSem) { |
| 7 | const [mean, sd] = calculateMeanAndSdOfRatioFromDeltaMethod( |
| 8 | prev, |
| 9 | current, |
| 10 | prevSem, |
| 11 | currentSem |
| 12 | ); |
| 13 | const pctChange = +(mean * 100).toFixed(1); |
| 14 | const ci95 = +(100 * 1.96 * sd).toFixed(1); |
| 15 | |
| 16 | const ciInfo = ci95 > 0 ? ` +- ${ci95} %` : ''; |
| 17 | const text = `${pctChange > 0 ? '+' : ''}${pctChange} %${ciInfo}`; |
| 18 | if (pctChange + ci95 < 0) { |
| 19 | return chalk.green(text); |
| 20 | } else if (pctChange - ci95 > 0) { |
| 21 | return chalk.red(text); |
| 22 | } else { |
| 23 | // Statistically insignificant. |
| 24 | return text; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | function calculateMeanAndSdOfRatioFromDeltaMethod( |
| 29 | meanControl, |
no test coverage detected