Skip to content

Commit 654c868

Browse files
mattipclaude
andcommitted
cache results
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 5eeb430 commit 654c868

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

codespeed/static/js/comparison.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var Comparison = (function(window){
33
// Localize globals
44
var readCheckbox = window.readCheckbox, getLoadText = window.getLoadText;
55

6-
var compdata, bench_units;
6+
var compdata, bench_units, dataCache = {};
77

88
function getConfiguration() {
99
return {
@@ -61,13 +61,14 @@ function refreshContent() {
6161
});
6262
}
6363

64-
function savedata(data) {
64+
function savedata(cacheKey, data) {
6565
if (data.error !== "None") {
6666
var h = $("#content").height();//get height for error message
6767
$("#plotwrapper").html(getLoadText(data.error, h));
6868
return 1;
6969
}
7070
delete data.error;
71+
dataCache[cacheKey] = data;
7172
compdata = data;
7273
refreshContent();
7374
}
@@ -91,9 +92,17 @@ function updateBaselineDropdown() {
9192
function loadData() {
9293
var conf = getConfiguration();
9394
if (!conf.exe || !conf.ben) { return; }
95+
var cacheKey = conf.exe + "|" + conf.ben;
96+
if (dataCache[cacheKey]) {
97+
compdata = dataCache[cacheKey];
98+
refreshContent();
99+
return;
100+
}
94101
var h = $("#content").height();
95102
$("#plotwrapper").html(getLoadText("Loading...", h));
96-
$.getJSON("json/", {exe: conf.exe, ben: conf.ben}, savedata);
103+
$.getJSON("json/", {exe: conf.exe, ben: conf.ben}, function(data) {
104+
savedata(cacheKey, data);
105+
});
97106
}
98107

99108
function abortRender(plotid, message) {

0 commit comments

Comments
 (0)