( entries, groupPrefix, chartId, title, yAxisTitle, conversionFactor = 1000, decimalPlaces = 1, thresholds = null, )
| 1007 | } |
| 1008 | |
| 1009 | function createCriterionGroupChart( |
| 1010 | entries, |
| 1011 | groupPrefix, |
| 1012 | chartId, |
| 1013 | title, |
| 1014 | yAxisTitle, |
| 1015 | conversionFactor = 1000, |
| 1016 | decimalPlaces = 1, |
| 1017 | thresholds = null, |
| 1018 | ) { |
| 1019 | const chartElement = document.getElementById(chartId); |
| 1020 | if (!chartElement) return; |
| 1021 | |
| 1022 | const criterionBenchmarks = Object.keys(entries[0].criterion_results).filter((benchmark) => |
| 1023 | benchmark.startsWith(groupPrefix + "/"), |
| 1024 | ); |
| 1025 | if (criterionBenchmarks.length === 0) return; |
| 1026 | |
| 1027 | const unitSuffix = yAxisTitle.includes("Nanoseconds") |
| 1028 | ? "ns" |
| 1029 | : yAxisTitle.includes("Microseconds") |
| 1030 | ? "μs" |
| 1031 | : yAxisTitle.includes("Milliseconds") |
| 1032 | ? "ms" |
| 1033 | : ""; |
| 1034 | |
| 1035 | function buildSeries(sampledEntries) { |
| 1036 | return criterionBenchmarks |
| 1037 | .map((benchmark) => { |
| 1038 | const dataPoints = sampledEntries |
| 1039 | .map((entry) => { |
| 1040 | const benchmarkData = entry.criterion_results[benchmark]; |
| 1041 | if (benchmarkData && benchmarkData.mean && benchmarkData.mean.point_estimate) { |
| 1042 | const convertedTime = benchmarkData.mean.point_estimate / conversionFactor; |
| 1043 | const roundedTime = |
| 1044 | Math.round(convertedTime * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces); |
| 1045 | return { |
| 1046 | x: new Date(entry.timestamp).getTime(), |
| 1047 | y: roundedTime, |
| 1048 | }; |
| 1049 | } |
| 1050 | return null; |
| 1051 | }) |
| 1052 | .filter((point) => point !== null); |
| 1053 | return { |
| 1054 | name: benchmark |
| 1055 | .replace(groupPrefix + "/", "") |
| 1056 | .replace(/\./g, " ") |
| 1057 | .replace(/-/g, " "), |
| 1058 | data: dataPoints, |
| 1059 | }; |
| 1060 | }) |
| 1061 | .filter((s) => s.data.length > 0); |
| 1062 | } |
| 1063 | |
| 1064 | const sampled = sampleEntries(entries); |
| 1065 | const series = buildSeries(sampled); |
| 1066 |
no test coverage detected