MCPcopy Create free account
hub / github.com/adobe/react-spectrum / summarizeConfirmation

Function summarizeConfirmation

perf/confirm.mjs:84–123  ·  view source on GitHub ↗
(original, originalDir, experiments, ids)

Source from the content-addressed store, hash-verified

82}
83
84export function summarizeConfirmation(original, originalDir, experiments, ids) {
85 let signed = value => {
86 let digits = Math.abs(value).toFixed(2);
87 // Values that round to zero get no minus sign.
88 return `${value < 0 && digits !== '0.00' ? '−' : '+'}${digits} ms`;
89 };
90 let cell = comparison =>
91 `${signed(comparison.delta)}${comparison.interval ? ` [${comparison.interval.map(signed).join(', ')}]` : ''} ${comparison.verdict}`;
92 let {options} = original;
93 let lines = [
94 '# Confirmation',
95 '',
96 `Original: ${originalDir} · ${original.builds.base.name} vs ${original.builds.candidate.name} · seed ${options.seed} · ${options.blocks} blocks × ${options.samples} trials · ${options.cpu}× CPU · ${options.scale}× workload`,
97 '',
98 `${experiments.length} confirmation run${experiments.length === 1 ? '' : 's'}, fixed before starting, with seeds ${experiments.map(experiment => experiment.seed).join(', ')} and otherwise identical settings.`,
99 '',
100 'Cells show the paired change, its interval, and the verdict. A scenario is confirmed when every confirmation run reaches the original verdict, not confirmed when any run contradicts it, and unresolved otherwise. The original run was often chosen because it showed an effect, so its estimate tends to overstate the change; judge the size from the confirmation runs.',
101 '',
102 `| Scenario | Original | ${experiments.map((_, i) => `Confirmation ${i + 1}`).join(' | ')} | Conclusion |`,
103 `|---|---|${experiments.map(() => '---|').join('')}---|`
104 ];
105 for (let id of ids) {
106 let first = original.comparisons[id];
107 let repeats = experiments.map(experiment => experiment.comparisons[id]);
108 lines.push(
109 `| ${id} | ${cell(first)} | ${repeats.map(cell).join(' | ')} | **${conclusion(
110 first.verdict,
111 repeats.map(comparison => comparison.verdict)
112 )}** |`
113 );
114 }
115 lines.push(
116 '',
117 'Runs:',
118 '',
119 ...experiments.map((experiment, i) => `- Confirmation ${i + 1}: ${experiment.dir}`),
120 ''
121 );
122 return lines.join('\n');
123}

Callers 2

confirm.test.mjsFile · 0.90
confirmFunction · 0.85

Calls 3

cellFunction · 0.85
conclusionFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected