Commit b599196d authored by ligaowei's avatar ligaowei

Add performance monitoring to TimelineContainer component

parent de7b8ee8
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onUnmounted } from 'vue' import { ref, onUnmounted, onMounted } from 'vue'
import TimelinePanel from './TimelinePanel.vue' import TimelinePanel from './TimelinePanel.vue'
import { TimelineEventStateManager } from '../services/timelineEventStateManager' import { TimelineEventStateManager } from '../services/timelineEventStateManager'
import { CacheService } from '../services/CacheService' import { CacheService } from '../services/CacheService'
...@@ -82,10 +82,18 @@ const handleClearTimeline = () => { ...@@ -82,10 +82,18 @@ const handleClearTimeline = () => {
cacheService.clearAllCaches(); cacheService.clearAllCaches();
}; };
// 显示性能统计信息
const showPerformanceStats = () => {
const stats = eventProcessor.getPerformanceStats();
console.log('[TimelineContainer] 性能统计:', stats);
alert(`总处理事件数: ${stats.totalProcessed}\n重用事件数: ${stats.totalReused}\n重用率: ${stats.reuseRate}%`);
};
// 暴露方法供父组件调用 // 暴露方法供父组件调用
defineExpose({ defineExpose({
addEvent, addEvent,
clearTimeline: handleClearTimeline clearTimeline: handleClearTimeline,
showPerformanceStats
}); });
// 组件卸载时清理资源 // 组件卸载时清理资源
...@@ -93,6 +101,20 @@ onUnmounted(() => { ...@@ -93,6 +101,20 @@ onUnmounted(() => {
stateManager.clearAllStates(); stateManager.clearAllStates();
cacheService.clearAllCaches(); cacheService.clearAllCaches();
}); });
// 组件挂载时启动定期性能监控
onMounted(() => {
// 每30秒输出一次性能统计
const perfInterval = setInterval(() => {
const stats = eventProcessor.getPerformanceStats();
console.log('[TimelineContainer] 定期性能统计:', stats);
}, 30000);
// 组件卸载时清除定时器
onUnmounted(() => {
clearInterval(perfInterval);
});
});
</script> </script>
<style scoped> <style scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment