载入中...
搜索中...
未找到
Profiler.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Capability.h"
6#include "common/GpuTimer.h"
7#include "common/Module.h"
8#include "common/Profile.h"
10#include "common/Result.h"
11
12#include <squirrel.h>
13
14#include <cstdint>
15#include <string>
16#include <unordered_set>
17#include <vector>
18
19namespace ssq {
20class Object;
21}
22
23namespace eve::profiler {
24
27 std::string module;
28 std::string name;
29 std::string thread;
30 double selfMs = 0.0;
31 double totalMs = 0.0;
32 int count = 0;
33 int depth = 0;
34};
35
38 uint64_t sequence = 0;
39 double cpuFrameMs = 0.0;
40 double gpuFrameMs = 0.0;
41 bool gpuTimingAvailable = false;
42 std::vector<ProfilerZoneSnapshot> zones;
43};
44
69public:
72 Profiler();
74 ~Profiler() override;
75
77 void setEnabled(bool on);
79 bool enabled() const;
81 void reset();
82
84 void beginFrame();
86 void endFrame();
87
92 void begin(const char* name);
94 void end();
95
97 bool hasFrame() const;
99 float frameMs() const;
101 float gpuFrameMs() const;
109 [[nodiscard]] eve::Result<ProfilerFrameSnapshot> captureFrame() const;
111 std::string textReport() const;
117 ssq::Object capture();
126 ssq::Object hotspots(int limit, float minSelfMs);
127
144 [[nodiscard]] const char* internScopeName(const std::string& name);
145
146 // IRenderTracer: route render passes into the core as "graphics" zones and
147 // drive automatic per-frame aggregation from the render frame boundary.
149 void frameBegin() override;
151 void frameEnd() override;
153 void passBegin(const char* name) override;
155 void passEnd(const char* name) override;
157 void draw(const char* api, const char* detail) override {}
158
159private:
161 void ensureGpuTimer() const;
162
163 int64_t frameBeginNs_ = 0;
164 float frameMs_ = 0.f;
165 uint64_t captureSequence_ = 0;
166 HSQUIRRELVM vm_ = nullptr;
168 std::unordered_set<std::string> scopeNames_;
170};
171
179
180} // namespace eve::profiler
struct SQVM * HSQUIRRELVM
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
int detail
Move-only, checked operation results for the common layer.
size_t begin
size_t end
int limit
Definition TreeMesh.cpp:166
EVENGINE_API_FOUNDATION public API.
Definition Module.h:48
Move-only operation result carrying either a value or Status.
Definition Result.h:176
One-shot borrowed capability pointer for composition roots and hot paths.
Definition Capability.h:107
Optional render-pipeline tracer. Graphics / RenderSystem call the rt* helpers; when no tracer is inst...
Definition RenderTrace.h:14
Script-facing wrapper around the engine-wide profiler core (eve::prof, see common/Profile....
Definition Profiler.h:68
void draw(const char *api, const char *detail) override
Draws .
Definition Profiler.h:157
EVENGINE_API_FOUNDATION void registerProfilerCapabilities()
Publish the read-only profiler capability (eve::IProfilerQuery).
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:21
bool enabled
Owning CPU/GPU profiler snapshot safe to retain across later frames.
Definition Profiler.h:37
std::vector< ProfilerZoneSnapshot > zones
Definition Profiler.h:42
One owning profiler row copied from the last completed frame.
Definition Profiler.h:26
std::string std::string name
Definition Profiler.h:28