Remove unnecessary debug outputs for production performance
This commit is contained in:
@@ -256,7 +256,7 @@ window.testDistributionChart = function() {
|
||||
};
|
||||
|
||||
// Debug flag - can be enabled even in production for troubleshooting
|
||||
const DEBUG_DISTRIBUTION = true;
|
||||
const DEBUG_DISTRIBUTION = false;
|
||||
|
||||
/**
|
||||
* Debug logger that works in production
|
||||
@@ -1002,43 +1002,39 @@ function updateSimulationProgress(data) {
|
||||
progressText.textContent = percentage.toFixed(1) + '%';
|
||||
}
|
||||
|
||||
// Update charts and metrics
|
||||
// Update charts and metrics only if we have new data
|
||||
if (data.iteration !== undefined) {
|
||||
currentSimulation.data.iterations.push(data.iteration);
|
||||
currentSimulation.data.totalWealth.push(data.total_wealth || 0);
|
||||
currentSimulation.data.giniCoefficients.push(data.gini_coefficient || 0);
|
||||
currentSimulation.data.capitalShare.push(data.capital_share || 0);
|
||||
currentSimulation.data.top10Share.push(data.wealth_concentration_top10 || 0);
|
||||
// Only update time series data occasionally to improve performance
|
||||
const shouldUpdateSeries = currentSimulation.data.iterations.length === 0 ||
|
||||
data.iteration % Math.max(1, Math.floor(currentSimulation.parameters.iterations / 200)) === 0 ||
|
||||
data.iteration === (currentSimulation.parameters.iterations - 1);
|
||||
|
||||
if (shouldUpdateSeries) {
|
||||
currentSimulation.data.iterations.push(data.iteration);
|
||||
currentSimulation.data.totalWealth.push(data.total_wealth || 0);
|
||||
currentSimulation.data.giniCoefficients.push(data.gini_coefficient || 0);
|
||||
currentSimulation.data.capitalShare.push(data.capital_share || 0);
|
||||
currentSimulation.data.top10Share.push(data.wealth_concentration_top10 || 0);
|
||||
}
|
||||
|
||||
// Update distribution data if available
|
||||
debugLog('Received simulation progress data', {
|
||||
hasDistribution: !!data.distribution,
|
||||
distribution: data.distribution,
|
||||
socketConnected: window.MarkovEconomics ? window.MarkovEconomics.isConnected : 'unknown'
|
||||
});
|
||||
|
||||
// More robust handling of distribution data
|
||||
if (data.distribution &&
|
||||
Array.isArray(data.distribution.labels) &&
|
||||
Array.isArray(data.distribution.counts) &&
|
||||
data.distribution.labels.length > 0 &&
|
||||
data.distribution.counts.length > 0) {
|
||||
|
||||
debugLog('Updating distribution data', {
|
||||
labelsLength: data.distribution.labels.length,
|
||||
countsLength: data.distribution.counts.length,
|
||||
labels: data.distribution.labels,
|
||||
counts: data.distribution.counts
|
||||
});
|
||||
|
||||
// Store the distribution data properly
|
||||
currentSimulation.data.distribution.labels = [...data.distribution.labels];
|
||||
currentSimulation.data.distribution.counts = [...data.distribution.counts];
|
||||
} else {
|
||||
debugLog('No valid distribution data in progress update');
|
||||
}
|
||||
|
||||
updateCharts();
|
||||
// Throttle chart updates to improve performance
|
||||
if (!window.lastChartUpdate || (Date.now() - window.lastChartUpdate) > 50) {
|
||||
updateCharts();
|
||||
window.lastChartUpdate = Date.now();
|
||||
}
|
||||
|
||||
updateMetricsDisplay(data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user