Browse Source

Throttling the update explorer for the MATLAB style data explorer had unnescessary function calls even when closed. Removed that for 20% perf. boost.

refactor/sync-centralize
RUSHIL AMBARISH KADU 6 months ago
parent
commit
8b667e6ad7
  1. 5
      steps/src/dataExplorer.js
  2. 4
      steps/src/sync.js

5
steps/src/dataExplorer.js

@ -31,6 +31,9 @@ let trackGridApi = null;
let chartInstance = null; let chartInstance = null;
let currentGridData = null; let currentGridData = null;
// --- EXPORTED STATE for Optimization ---
export let isExplorerOpen = false;
// --- AG Grid Configuration --- // --- AG Grid Configuration ---
const gridOptions = { const gridOptions = {
rowData: [], rowData: [],
@ -102,11 +105,13 @@ function createChart(data, label) {
function showExplorer() { function showExplorer() {
panel.classList.remove('hidden'); panel.classList.remove('hidden');
isExplorerOpen = true; // Update state
updateExplorer(); updateExplorer();
} }
function hideExplorer() { function hideExplorer() {
panel.classList.add('hidden'); panel.classList.add('hidden');
isExplorerOpen = false; // Update state
} }
function switchTab(targetTab) { function switchTab(targetTab) {

4
steps/src/sync.js

@ -15,7 +15,7 @@ import {
} from "./dom.js"; } from "./dom.js";
import { VIDEO_FPS } from "./constants.js"; import { VIDEO_FPS } from "./constants.js";
import { findRadarFrameIndexForTime, precomputeRadarVideoSync } from "./utils.js"; import { findRadarFrameIndexForTime, precomputeRadarVideoSync } from "./utils.js";
import { throttledUpdateExplorer } from "./dataExplorer.js";
import { throttledUpdateExplorer, isExplorerOpen } from "./dataExplorer.js";
import { debugFlags } from "./debug.js"; import { debugFlags } from "./debug.js";
// --- [START] MOVED FROM DOM.JS --- // --- [START] MOVED FROM DOM.JS ---
@ -137,7 +137,9 @@ export function updateFrame(frame, forceVideoSeek = false, overrideTime = null)
// We no longer call redraw() from here. // We no longer call redraw() from here.
// --- NEW: Centralized Explorer Update --- // --- NEW: Centralized Explorer Update ---
if (isExplorerOpen) {
throttledUpdateExplorer(); throttledUpdateExplorer();
}
// --- END: Centralized Explorer Update --- // --- END: Centralized Explorer Update ---
const endTime = performance.now(); const endTime = performance.now();
appState.lastFrameRenderTime = endTime - startTime; // <-- End timer and update state appState.lastFrameRenderTime = endTime - startTime; // <-- End timer and update state

Loading…
Cancel
Save