Feature/advanced profiler (#249)
* feat(profiler): 实现高级性能分析器 * test(core): 添加 ProfilerSDK 和 AdvancedProfilerCollector 测试覆盖 * test(core): 添加 ProfilerSDK 和 AdvancedProfilerCollector 测试覆盖 * test(core): 添加 ProfilerSDK 和 AdvancedProfilerCollector 测试覆盖
This commit is contained in:
@@ -512,6 +512,15 @@ export class Core {
|
|||||||
return this._instance?._config.debugConfig?.enabled || false;
|
return this._instance?._config.debugConfig?.enabled || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取性能监视器实例
|
||||||
|
*
|
||||||
|
* @returns 性能监视器,如果Core未初始化则返回null
|
||||||
|
*/
|
||||||
|
public static get performanceMonitor(): PerformanceMonitor | null {
|
||||||
|
return this._instance?._performanceMonitor || null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装插件
|
* 安装插件
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -27,13 +27,11 @@ export function ProfilerPanel() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const coreInstance = Core.Instance;
|
const performanceMonitor = Core.performanceMonitor;
|
||||||
if (!coreInstance || !coreInstance._performanceMonitor?.isEnabled) {
|
if (!performanceMonitor?.isEnabled) {
|
||||||
animationRef.current = requestAnimationFrame(updateProfilerData);
|
animationRef.current = requestAnimationFrame(updateProfilerData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const performanceMonitor = coreInstance._performanceMonitor;
|
|
||||||
const systemDataMap = performanceMonitor.getAllSystemData();
|
const systemDataMap = performanceMonitor.getAllSystemData();
|
||||||
const systemStatsMap = performanceMonitor.getAllSystemStats();
|
const systemStatsMap = performanceMonitor.getAllSystemStats();
|
||||||
|
|
||||||
@@ -91,10 +89,7 @@ export function ProfilerPanel() {
|
|||||||
}, [isPaused, sortBy]);
|
}, [isPaused, sortBy]);
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
const coreInstance = Core.Instance;
|
Core.performanceMonitor?.reset();
|
||||||
if (coreInstance && coreInstance._performanceMonitor) {
|
|
||||||
coreInstance._performanceMonitor.reset();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fps = totalFrameTime > 0 ? Math.round(1000 / totalFrameTime) : 0;
|
const fps = totalFrameTime > 0 ? Math.round(1000 / totalFrameTime) : 0;
|
||||||
|
|||||||
@@ -156,13 +156,11 @@ export function ProfilerWindow({ onClose }: ProfilerWindowProps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const coreInstance = Core.Instance;
|
const performanceMonitor = Core.performanceMonitor;
|
||||||
if (!coreInstance || !coreInstance._performanceMonitor?.isEnabled) {
|
if (!performanceMonitor?.isEnabled) {
|
||||||
animationRef.current = requestAnimationFrame(updateProfilerData);
|
animationRef.current = requestAnimationFrame(updateProfilerData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const performanceMonitor = coreInstance._performanceMonitor;
|
|
||||||
const systemDataMap = performanceMonitor.getAllSystemData();
|
const systemDataMap = performanceMonitor.getAllSystemData();
|
||||||
const systemStatsMap = performanceMonitor.getAllSystemStats();
|
const systemStatsMap = performanceMonitor.getAllSystemStats();
|
||||||
|
|
||||||
@@ -219,10 +217,7 @@ export function ProfilerWindow({ onClose }: ProfilerWindowProps) {
|
|||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
if (dataSource === 'local') {
|
if (dataSource === 'local') {
|
||||||
const coreInstance = Core.Instance;
|
Core.performanceMonitor?.reset();
|
||||||
if (coreInstance && coreInstance._performanceMonitor) {
|
|
||||||
coreInstance._performanceMonitor.reset();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Reset remote data
|
// Reset remote data
|
||||||
setSystems([]);
|
setSystems([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user