7
7
let activeRuns = new Set ( defaultCompareNames ) ;
8
8
let chartInstances = new Map ( ) ;
9
9
let suiteNames = new Set ( ) ;
10
- let timeseriesData , barChartsData , allRunNames ;
11
10
let activeTags = new Set ( ) ;
11
+ let timeseriesData , barChartsData , allRunNames ;
12
12
let layerComparisonsData ;
13
13
let latestRunsLookup = new Map ( ) ;
14
14
let pendingCharts = new Map ( ) ; // Store chart data for lazy loading
15
15
let chartObserver ; // Intersection observer for lazy loading charts
16
16
let annotationsOptions = new Map ( ) ; // Global options map for annotations
17
+ let archivedDataLoaded = false ;
17
18
18
19
// DOM Elements
19
20
let runSelect , selectedRunsDiv , suiteFiltersContainer , tagFiltersContainer ;
@@ -577,6 +578,12 @@ function updateURL() {
577
578
} else {
578
579
url . searchParams . set ( 'customRange' , 'true' ) ;
579
580
}
581
+
582
+ if ( ! isArchivedDataEnabled ( ) ) {
583
+ url . searchParams . delete ( 'archived' ) ;
584
+ } else {
585
+ url . searchParams . set ( 'archived' , 'true' ) ;
586
+ }
580
587
581
588
history . replaceState ( null , '' , url ) ;
582
589
}
@@ -835,6 +842,9 @@ function setupRunSelector() {
835
842
runSelect = document . getElementById ( 'run-select' ) ;
836
843
selectedRunsDiv = document . getElementById ( 'selected-runs' ) ;
837
844
845
+ // Clear existing options first to prevent duplicates when reloading with archived data
846
+ runSelect . innerHTML = '' ;
847
+
838
848
allRunNames . forEach ( name => {
839
849
const option = document . createElement ( 'option' ) ;
840
850
option . value = name ;
@@ -848,6 +858,9 @@ function setupRunSelector() {
848
858
function setupSuiteFilters ( ) {
849
859
suiteFiltersContainer = document . getElementById ( 'suite-filters' ) ;
850
860
861
+ // Clear existing suite filters before adding new ones
862
+ suiteFiltersContainer . innerHTML = '' ;
863
+
851
864
benchmarkRuns . forEach ( run => {
852
865
run . results . forEach ( result => {
853
866
suiteNames . add ( result . suite ) ;
@@ -883,10 +896,16 @@ function isCustomRangesEnabled() {
883
896
return rangesToggle . checked ;
884
897
}
885
898
899
+ function isArchivedDataEnabled ( ) {
900
+ const archivedDataToggle = document . getElementById ( 'show-archived-data' ) ;
901
+ return archivedDataToggle . checked ;
902
+ }
903
+
886
904
function setupToggles ( ) {
887
905
const notesToggle = document . getElementById ( 'show-notes' ) ;
888
906
const unstableToggle = document . getElementById ( 'show-unstable' ) ;
889
907
const customRangeToggle = document . getElementById ( 'custom-range' ) ;
908
+ const archivedDataToggle = document . getElementById ( 'show-archived-data' ) ;
890
909
891
910
notesToggle . addEventListener ( 'change' , function ( ) {
892
911
// Update all note elements visibility
@@ -908,10 +927,26 @@ function setupToggles() {
908
927
// redraw all charts
909
928
updateCharts ( ) ;
910
929
} ) ;
930
+
931
+ // Add event listener for archived data toggle
932
+ if ( archivedDataToggle ) {
933
+ archivedDataToggle . addEventListener ( 'change' , function ( ) {
934
+ if ( archivedDataToggle . checked ) {
935
+ loadArchivedData ( ) ;
936
+ } else {
937
+ if ( archivedDataLoaded ) {
938
+ // Reload the page to reset
939
+ location . reload ( ) ;
940
+ }
941
+ }
942
+ updateURL ( ) ;
943
+ } ) ;
944
+ }
911
945
912
946
// Initialize from URL params if present
913
947
const notesParam = getQueryParam ( 'notes' ) ;
914
948
const unstableParam = getQueryParam ( 'unstable' ) ;
949
+ const archivedParam = getQueryParam ( 'archived' ) ;
915
950
916
951
if ( notesParam !== null ) {
917
952
let showNotes = notesParam === 'true' ;
@@ -927,11 +962,22 @@ function setupToggles() {
927
962
if ( customRangesParam !== null ) {
928
963
customRangeToggle . checked = customRangesParam === 'true' ;
929
964
}
965
+
966
+ if ( archivedDataToggle && archivedParam !== null ) {
967
+ archivedDataToggle . checked = archivedParam === 'true' ;
968
+
969
+ if ( archivedDataToggle . checked ) {
970
+ loadArchivedData ( ) ;
971
+ }
972
+ }
930
973
}
931
974
932
975
function setupTagFilters ( ) {
933
976
tagFiltersContainer = document . getElementById ( 'tag-filters' ) ;
934
977
978
+ // Clear existing tag filters before adding new ones
979
+ tagFiltersContainer . innerHTML = '' ;
980
+
935
981
const allTags = [ ] ;
936
982
937
983
if ( benchmarkTags ) {
@@ -1119,6 +1165,94 @@ function loadData() {
1119
1165
}
1120
1166
}
1121
1167
1168
+ // Function to load archived data and merge with current data
1169
+ // Archived data consists of older benchmark results that have been separated from
1170
+ // the primary dataset but are still available for historical analysis.
1171
+ function loadArchivedData ( ) {
1172
+ const loadingIndicator = document . getElementById ( 'loading-indicator' ) ;
1173
+ loadingIndicator . style . display = 'block' ;
1174
+
1175
+ if ( archivedDataLoaded ) {
1176
+ updateCharts ( ) ;
1177
+ loadingIndicator . style . display = 'none' ;
1178
+ return ;
1179
+ }
1180
+
1181
+ if ( typeof remoteDataUrl !== 'undefined' && remoteDataUrl !== '' ) {
1182
+ // For remote data, construct the archive URL by adding _archive before the extension
1183
+ const archiveUrl = remoteDataUrl . replace ( / ( \. [ ^ . ] + ) $ / , '_archive$1' ) ;
1184
+
1185
+ fetch ( archiveUrl )
1186
+ . then ( response => {
1187
+ if ( ! response . ok ) { throw new Error ( `Got response status ${ response . status } .` ) }
1188
+ return response . json ( ) ;
1189
+ } )
1190
+ . then ( data => {
1191
+ const archivedRuns = data . runs || data ;
1192
+
1193
+ // Merge the archived runs with current runs
1194
+ benchmarkRuns = benchmarkRuns . concat ( archivedRuns ) ;
1195
+
1196
+ // Merge metadata and tags if available
1197
+ if ( data . metadata ) {
1198
+ benchmarkMetadata = { ...benchmarkMetadata , ...data . metadata } ;
1199
+ }
1200
+
1201
+ if ( data . tags ) {
1202
+ benchmarkTags = { ...benchmarkTags , ...data . tags } ;
1203
+ }
1204
+
1205
+ archivedDataLoaded = true ;
1206
+ initializeCharts ( ) ;
1207
+ } )
1208
+ . catch ( error => {
1209
+ console . error ( 'Error fetching archived data:' , error ) ;
1210
+ } )
1211
+ . finally ( ( ) => {
1212
+ loadingIndicator . style . display = 'none' ;
1213
+ } ) ;
1214
+ } else {
1215
+ // For local data, try to load data_archive.js
1216
+ const script = document . createElement ( 'script' ) ;
1217
+ script . src = 'data_archive.js' ;
1218
+ script . onload = ( ) => {
1219
+ if ( typeof archivedBenchmarkRuns !== 'undefined' ) {
1220
+ // Merge the archived runs with current runs
1221
+ benchmarkRuns = benchmarkRuns . concat ( archivedBenchmarkRuns ) ;
1222
+
1223
+ // Merge metadata and tags if available
1224
+ if ( typeof archivedBenchmarkMetadata !== 'undefined' ) {
1225
+ benchmarkMetadata = { ...benchmarkMetadata , ...archivedBenchmarkMetadata } ;
1226
+ }
1227
+
1228
+ if ( typeof archivedBenchmarkTags !== 'undefined' ) {
1229
+ benchmarkTags = { ...benchmarkTags , ...archivedBenchmarkTags } ;
1230
+ }
1231
+
1232
+ archivedDataLoaded = true ;
1233
+
1234
+ archivedBenchmarkRuns . forEach ( runName => {
1235
+ if ( ! activeRuns . has ( runName ) ) {
1236
+ activeRuns . add ( runName ) ;
1237
+ }
1238
+ } ) ;
1239
+
1240
+ initializeCharts ( ) ;
1241
+ } else {
1242
+ console . error ( 'Archived runs data not found in data_archive.js' ) ;
1243
+ }
1244
+ loadingIndicator . style . display = 'none' ;
1245
+ } ;
1246
+
1247
+ script . onerror = ( ) => {
1248
+ console . error ( 'Failed to load data_archive.js' ) ;
1249
+ loadingIndicator . style . display = 'none' ;
1250
+ } ;
1251
+
1252
+ document . head . appendChild ( script ) ;
1253
+ }
1254
+ }
1255
+
1122
1256
// Initialize when DOM is ready
1123
1257
document . addEventListener ( 'DOMContentLoaded' , ( ) => {
1124
1258
loadData ( ) ;
0 commit comments