@@ -3,7 +3,7 @@ var Comparison = (function(window){
33// Localize globals
44var readCheckbox = window . readCheckbox , getLoadText = window . getLoadText ;
55
6- var compdata , bench_units ;
6+ var compdata , bench_units , dataCache = { } ;
77
88function 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() {
9192function 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
99108function abortRender ( plotid , message ) {
0 commit comments