Remove unnecessary debug outputs for production performance
This commit is contained in:
@@ -26,13 +26,13 @@ function initializeSocket() {
|
||||
window.MarkovEconomics.socket = io();
|
||||
|
||||
window.MarkovEconomics.socket.on('connect', function() {
|
||||
console.log('Connected to server');
|
||||
// console.log('Connected to server');
|
||||
window.MarkovEconomics.isConnected = true;
|
||||
updateConnectionStatus(true);
|
||||
});
|
||||
|
||||
window.MarkovEconomics.socket.on('disconnect', function() {
|
||||
console.log('Disconnected from server');
|
||||
// console.log('Disconnected from server');
|
||||
window.MarkovEconomics.isConnected = false;
|
||||
updateConnectionStatus(false);
|
||||
});
|
||||
@@ -50,9 +50,9 @@ function initializeSocket() {
|
||||
function updateConnectionStatus(connected) {
|
||||
// You can add a connection status indicator here if needed
|
||||
if (connected) {
|
||||
console.log('✅ Real-time connection established');
|
||||
// console.log('✅ Real-time connection established');
|
||||
} else {
|
||||
console.log('❌ Real-time connection lost');
|
||||
// console.log('❌ Real-time connection lost');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
card.classList.add('fade-in');
|
||||
});
|
||||
|
||||
console.log('🚀 Markov Economics application initialized');
|
||||
// console.log('🚀 Markov Economics application initialized');
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -259,9 +259,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
*/
|
||||
document.addEventListener('visibilitychange', function() {
|
||||
if (document.hidden) {
|
||||
console.log('Page hidden - pausing updates');
|
||||
// console.log('Page hidden - pausing updates');
|
||||
} else {
|
||||
console.log('Page visible - resuming updates');
|
||||
// console.log('Page visible - resuming updates');
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -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