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

Function launchSection

perf/report.mjs:246–323  ·  view source on GitHub ↗
(result)

Source from the content-addressed store, hash-verified

244
245// Per-launch paired changes, for inspecting drift over a run and order effects.
246function launchSection(result) {
247 let blocks = [...new Set(result.samples.map(sample => sample.block))].sort((a, b) => a - b);
248 if (!result.builds.candidate || !blocks.length) {
249 return [];
250 }
251 let signed = value => {
252 let digits = Math.abs(value).toFixed(2);
253 // Values that round to zero get no minus sign.
254 return `${value < 0 && digits !== '0.00' ? '−' : '+'}${digits}`;
255 };
256 let lines = [
257 '',
258 '## Changes by browser launch',
259 '',
260 'Each cell is one launch’s paired change in milliseconds (candidate median minus base median), marked B or C for the arm that led that launch’s ABBA trials. The last two columns are medians over launches led by each arm; a consistent gap between them suggests an order effect. A trend across launches suggests drift during the run.',
261 ''
262 ];
263 let starts = blocks.map(block =>
264 Math.min(
265 ...(result.order ?? [])
266 .filter(entry => entry.block === block && entry.started !== undefined)
267 .map(entry => entry.started)
268 )
269 );
270 if (starts.every(Number.isFinite)) {
271 lines.push(
272 `Launch start times, in minutes into the run: ${starts.map(start => (start / 60000).toFixed(1)).join(', ')}.`,
273 ''
274 );
275 }
276 lines.push(
277 `| Scenario | ${blocks.map(block => `L${block + 1}`).join(' | ')} | Base led | Candidate led |`,
278 `|---|${blocks.map(() => '---:').join('|')}|---:|---:|`
279 );
280 for (let scenario of result.scenarios) {
281 let metric = scenario.metric ?? 'opportunity';
282 let cells = blocks.map(block => {
283 let median = arm =>
284 percentile(
285 result.samples
286 .filter(
287 sample =>
288 sample.scenario === scenario.id && sample.block === block && sample.arm === arm
289 )
290 .map(sample => sample.metrics[metric]),
291 0.5
292 );
293 let base = median('base');
294 let candidate = median('candidate');
295 return {
296 delta: base === null || candidate === null ? null : candidate - base,
297 led: result.order?.find(entry => entry.block === block && entry.scenario === scenario.id)
298 ?.arms[0]
299 };
300 });
301 let byLead = arm => {
302 let deltas = cells.filter(cell => cell.led === arm && cell.delta !== null);
303 return deltas.length

Callers 1

reportFunction · 0.85

Calls 6

medianFunction · 0.85
byLeadFunction · 0.85
pushMethod · 0.80
signedFunction · 0.70
sortMethod · 0.65
filterMethod · 0.65

Tested by

no test coverage detected