Skip to content

Commit 73a381f

Browse files
authored
[Benchmarks] Speed up charts load (#18728)
Dates can be compared directly as strings, it works. There is no need for expensive Date object creation and comparing Date objects.
1 parent 735410d commit 73a381f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

devops/scripts/benchmarks/html/scripts.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let suiteNames = new Set();
1010
let timeseriesData, barChartsData, allRunNames;
1111
let activeTags = new Set();
1212
let layerComparisonsData;
13+
let latestRunsLookup = new Map();
1314

1415
// DOM Elements
1516
let runSelect, selectedRunsDiv, suiteFiltersContainer, tagFiltersContainer;
@@ -342,8 +343,7 @@ function createChartContainer(data, canvasId, type) {
342343
// Create and append extra info
343344
const extraInfo = document.createElement('div');
344345
extraInfo.className = 'extra-info';
345-
latestRunsLookup = createLatestRunsLookup(benchmarkRuns);
346-
extraInfo.innerHTML = generateExtraInfo(latestRunsLookup, data, 'benchmark');
346+
extraInfo.innerHTML = generateExtraInfo(data, 'benchmark');
347347
details.appendChild(extraInfo);
348348

349349
container.appendChild(details);
@@ -371,11 +371,10 @@ function createLatestRunsLookup(benchmarkRuns) {
371371
const latestRunsMap = new Map();
372372

373373
benchmarkRuns.forEach(run => {
374-
// Yes, we need to convert the date every time. I checked.
375-
const runDate = new Date(run.date);
374+
const runDate = run.date;
376375
run.results.forEach(result => {
377376
const label = result.label;
378-
if (!latestRunsMap.has(label) || runDate > new Date(latestRunsMap.get(label).date)) {
377+
if (!latestRunsMap.has(label) || runDate > latestRunsMap.get(label).date) {
379378
latestRunsMap.set(label, {
380379
run,
381380
result
@@ -417,7 +416,7 @@ function getDisplayLabel(label, data, metadata) {
417416
return label;
418417
}
419418

420-
function generateExtraInfo(latestRunsLookup, data, type = 'benchmark') {
419+
function generateExtraInfo(data, type = 'benchmark') {
421420
const labels = extractLabels(data);
422421

423422
return labels.map(label => {
@@ -958,6 +957,7 @@ function initializeCharts() {
958957
barChartsData = processBarChartsData(benchmarkRuns);
959958
layerComparisonsData = processLayerComparisonsData(benchmarkRuns);
960959
allRunNames = [...new Set(benchmarkRuns.map(run => run.name))];
960+
latestRunsLookup = createLatestRunsLookup(benchmarkRuns);
961961

962962
// Set up active runs
963963
const runsParam = getQueryParam('runs');

0 commit comments

Comments
 (0)