Files
XCEngine/docs/api/debug/profiler/exportchrometracing.md

50 lines
1.2 KiB
Markdown
Raw Normal View History

# Profiler::ExportChromeTracing
```cpp
void ExportChromeTracing(const Containers::String& filePath)
```
**状态:** 此方法目前为空实现,暂未功能。
将收集的性能数据导出为 Chrome Tracing JSON 格式。导出的文件可通过 Chrome 浏览器打开(地址栏输入 `chrome://tracing` 并加载文件)进行可视化分析。
**参数:**
- `filePath` - 输出文件路径
2026-03-20 02:35:07 +08:00
**返回:** `void`
**线程安全:** ✅ 线程安全
**复杂度:** O(n)n 为记录的样本数量
**示例:**
```cpp
#include <XCEngine/Debug/Profiler.h>
XCEngine::Debug::Profiler::Get().Initialize();
void RenderFrame() {
XCEngine::Debug::Profiler::Get().BeginFrame();
XE_PROFILE_FUNCTION();
XE_PROFILE_BEGIN("UpdateScene");
UpdateScene();
XE_PROFILE_END();
XE_PROFILE_BEGIN("DrawScene");
DrawScene();
XE_PROFILE_END();
XCEngine::Debug::Profiler::Get().EndFrame();
}
2026-03-20 02:35:07 +08:00
// 运行一段时间后导出(需在 Shutdown 前调用)
XCEngine::Debug::Profiler::Get().ExportChromeTracing("trace.json");
XCEngine::Debug::Profiler::Get().Shutdown();
```
## 相关文档
- [Profiler 总览](profiler.md) - 返回类总览