49 lines
843 B
Markdown
49 lines
843 B
Markdown
# Profiler::EndProfile
|
|
|
|
结束最近一次开始的 profile 区段,并记录其耗时。
|
|
|
|
```cpp
|
|
void EndProfile();
|
|
```
|
|
|
|
## 行为说明
|
|
|
|
当前实现会:
|
|
|
|
1. 检查内部栈是否为空;为空则直接返回。
|
|
2. 读取当前微秒时间作为结束时间。
|
|
3. 弹出最近一个 `ProfileNode`。
|
|
4. 计算区段耗时并把结果追加到内部 `m_samples`。
|
|
|
|
当前不会:
|
|
|
|
- 验证开始与结束是否发生在同一线程。
|
|
- 提供读取样本的公开 API。
|
|
|
|
## 参数
|
|
|
|
- 无。
|
|
|
|
## 返回值
|
|
|
|
- 无。
|
|
|
|
## 线程语义
|
|
|
|
- 必须与 [BeginProfile](BeginProfile.md) 形成正确的 LIFO 配对。
|
|
|
|
## 示例
|
|
|
|
```cpp
|
|
using namespace XCEngine::Debug;
|
|
|
|
Profiler::Get().BeginProfile("FrameBuild");
|
|
// ...
|
|
Profiler::Get().EndProfile();
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [返回类型总览](Profiler.md)
|
|
- [BeginProfile](BeginProfile.md)
|