MCPcopy Index your code
hub / github.com/react/react / percentChange

Function percentChange

scripts/bench/stats.js:6–26  ·  view source on GitHub ↗
(prev, current, prevSem, currentSem)

Source from the content-addressed store, hash-verified

4const Table = require('cli-table');
5
6function 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
28function calculateMeanAndSdOfRatioFromDeltaMethod(
29 meanControl,

Callers 1

addBenchmarkResultsFunction · 0.85

Tested by

no test coverage detected