MCPcopy Create free account
hub / github.com/csskit/csskit / createTimeChart

Function createTimeChart

website/script/benchmarks.js:443–568  ·  view source on GitHub ↗
(entries)

Source from the content-addressed store, hash-verified

441}
442
443function createTimeChart(entries) {
444 const chartElement = document.getElementById("processing-time-chart");
445 if (!chartElement) return;
446
447 const allFiles = Object.keys(entries[0].hyperfine_results);
448
449 function buildSeries(sampledEntries) {
450 return allFiles.map((file) => {
451 const dataPoints = sampledEntries
452 .map((entry) => {
453 const fileData = entry.hyperfine_results[file];
454 if (fileData && fileData.results && fileData.results[0]) {
455 return {
456 x: new Date(entry.timestamp).getTime(),
457 y: Math.round(fileData.results[0].mean * 1000000), // microseconds
458 };
459 }
460 return null;
461 })
462 .filter((point) => point !== null);
463 return {
464 name: file.replace(/\./g, " ").replace(/-/g, " "),
465 data: dataPoints,
466 };
467 });
468 }
469
470 const sampled = sampleEntries(entries);
471 const series = buildSeries(sampled);
472
473 // Detect outliers
474 let allValues = [];
475 series.forEach((s) => {
476 s.data.forEach((point) => allValues.push(point.y));
477 });
478
479 const { outliers, normal } = detectOutliers(allValues);
480 const hasOutliers = outliers.length > 0;
481
482 const normalSeries = [];
483 const outlierSeries = [];
484 series.forEach((s) => {
485 const avgValue = s.data.reduce((sum, point) => sum + point.y, 0) / s.data.length;
486 if (outliers.includes(avgValue) || s.data.some((point) => outliers.includes(point.y))) {
487 outlierSeries.push(s);
488 } else {
489 normalSeries.push(s);
490 }
491 });
492
493 function buildNormalSeries(e) {
494 return buildSeries(e).filter((s) => normalSeries.some((ns) => ns.name === s.name));
495 }
496 function buildOutlierSeries(e) {
497 return buildSeries(e).filter((s) => outlierSeries.some((os) => os.name === s.name));
498 }
499
500 const mainMin = normal.length > 0 ? Math.max(0, Math.min(...normal)) : 0;

Callers 1

initializeChartsFunction · 0.85

Calls 7

sampleEntriesFunction · 0.85
buildSeriesFunction · 0.85
detectOutliersFunction · 0.85
getBaseChartConfigFunction · 0.85
buildZoomEventsFunction · 0.85
sampledTimeRangeFunction · 0.85
renderMethod · 0.80

Tested by

no test coverage detected