Made Faster
This commit is contained in:
parent
8e5655abb3
commit
a5fd89168b
34
imgui.ini
34
imgui.ini
@ -10,24 +10,24 @@ Collapsed=1
|
|||||||
|
|
||||||
[Window][WindowOverViewport_11111111]
|
[Window][WindowOverViewport_11111111]
|
||||||
Pos=0,19
|
Pos=0,19
|
||||||
Size=1920,1158
|
Size=1280,701
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Inspector]
|
[Window][Inspector]
|
||||||
Pos=0,683
|
Pos=0,421
|
||||||
Size=342,494
|
Size=342,299
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000A,0
|
DockId=0x0000000A,0
|
||||||
|
|
||||||
[Window][Scene Tree]
|
[Window][Scene Tree]
|
||||||
Pos=0,19
|
Pos=0,19
|
||||||
Size=342,662
|
Size=342,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000009,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=344,19
|
Pos=344,19
|
||||||
Size=1576,535
|
Size=936,78
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000B,0
|
DockId=0x0000000B,0
|
||||||
|
|
||||||
@ -36,14 +36,14 @@ Size=1280,19
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Performance Info]
|
[Window][Performance Info]
|
||||||
Pos=1588,840
|
Pos=1083,383
|
||||||
Size=332,118
|
Size=197,118
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000003,0
|
DockId=0x00000003,0
|
||||||
|
|
||||||
[Window][Console]
|
[Window][Console]
|
||||||
Pos=344,840
|
Pos=344,383
|
||||||
Size=612,337
|
Size=363,337
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000D,0
|
DockId=0x0000000D,0
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ Collapsed=0
|
|||||||
DockId=0x0000000B,1
|
DockId=0x0000000B,1
|
||||||
|
|
||||||
[Window][Profiler]
|
[Window][Profiler]
|
||||||
Pos=344,556
|
Pos=344,99
|
||||||
Size=1576,282
|
Size=936,282
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
@ -78,26 +78,26 @@ Collapsed=0
|
|||||||
DockId=0x00000005,1
|
DockId=0x00000005,1
|
||||||
|
|
||||||
[Window][Color Correction]
|
[Window][Color Correction]
|
||||||
Pos=1588,960
|
Pos=1083,503
|
||||||
Size=332,217
|
Size=197,217
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
[Window][Asset Browser]
|
[Window][Asset Browser]
|
||||||
Pos=958,840
|
Pos=709,383
|
||||||
Size=628,337
|
Size=372,337
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000E,0
|
DockId=0x0000000E,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x11111111 Window=0x1BBC0F80 Pos=0,19 Size=1920,1158 Split=X
|
DockSpace ID=0x11111111 Window=0x1BBC0F80 Pos=0,19 Size=1280,701 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x11111111 SizeRef=342,701 Split=Y Selected=0x12EF0F59
|
DockNode ID=0x00000001 Parent=0x11111111 SizeRef=342,701 Split=Y Selected=0x12EF0F59
|
||||||
DockNode ID=0x00000009 Parent=0x00000001 SizeRef=385,662 HiddenTabBar=1 Selected=0x12EF0F59
|
DockNode ID=0x00000009 Parent=0x00000001 SizeRef=385,662 HiddenTabBar=1 Selected=0x12EF0F59
|
||||||
DockNode ID=0x0000000A Parent=0x00000001 SizeRef=385,494 HiddenTabBar=1 Selected=0x36DC96AB
|
DockNode ID=0x0000000A Parent=0x00000001 SizeRef=385,494 HiddenTabBar=1 Selected=0x36DC96AB
|
||||||
DockNode ID=0x00000002 Parent=0x11111111 SizeRef=1576,701 Split=Y Selected=0xC450F867
|
DockNode ID=0x00000002 Parent=0x11111111 SizeRef=1576,701 Split=Y Selected=0xC450F867
|
||||||
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=606,819 Split=Y Selected=0xC450F867
|
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=606,819 Split=Y Selected=0xC450F867
|
||||||
DockNode ID=0x0000000B Parent=0x00000007 SizeRef=1576,535 CentralNode=1 HiddenTabBar=1 Selected=0xC450F867
|
DockNode ID=0x0000000B Parent=0x00000007 SizeRef=1576,535 CentralNode=1 HiddenTabBar=1 Selected=0xC450F867
|
||||||
DockNode ID=0x0000000C Parent=0x00000007 SizeRef=1576,282 Selected=0x9B5D3198
|
DockNode ID=0x0000000C Parent=0x00000007 SizeRef=1576,282 HiddenTabBar=1 Selected=0x9B5D3198
|
||||||
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=606,337 Split=X Selected=0x9B5D3198
|
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=606,337 Split=X Selected=0x9B5D3198
|
||||||
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=737,481 Split=X Selected=0x9B5D3198
|
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=737,481 Split=X Selected=0x9B5D3198
|
||||||
DockNode ID=0x0000000D Parent=0x00000005 SizeRef=363,248 HiddenTabBar=1 Selected=0xEA83D666
|
DockNode ID=0x0000000D Parent=0x00000005 SizeRef=363,248 HiddenTabBar=1 Selected=0xEA83D666
|
||||||
|
36635
profile_export.json
36635
profile_export.json
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,3 @@
|
|||||||
[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d -IC:/msys64/mingw64/include -Isrc\vendor\imgui -IC:\msys64\mingw64\lib\libyaml-cpp.a -MMD -MP -c src\src\Engine.cpp -o src\build\Engine.o
|
[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d -IC:/msys64/mingw64/include -Isrc\vendor\imgui -IC:\msys64\mingw64\lib\libyaml-cpp.a -MMD -MP -c src\src\core\utils\Profiler.cpp -o src\build\core\utils\Profiler.o
|
||||||
[LINK] g++ src\build\Engine.o src\build\main.o src\build\Renderer.o src\build\Components\CameraComponent.o src\build\Components\LightComponent.o src\build\Components\PhysicsComponent.o src\build\Components\ScriptComponent.o src\build\Components\SpriteComponent.o src\build\Components\TextComonent.o src\build\Components\TilemapComponent.o src\build\core\utils\AssetLoader.o src\build\core\utils\EngineConfig.o src\build\core\utils\ExceptionHandler.o src\build\core\utils\FileDialog.o src\build\core\utils\input.o src\build\core\utils\Logging.o src\build\core\utils\Profiler.o src\build\core\utils\utils.o src\build\editor\windows\AssetBrowser.o src\build\editor\windows\Inspector.o src\build\Entitys\Object.o src\build\utils\GameObjectsList.o src\build\utils\Shader.o src\build\utils\UID.o src\build\lapi.o src\build\lauxlib.o src\build\lbaselib.o src\build\lcode.o src\build\lcorolib.o src\build\lctype.o src\build\ldblib.o src\build\ldebug.o src\build\ldo.o src\build\ldump.o src\build\lfunc.o src\build\lgc.o src\build\linit.o src\build\liolib.o src\build\llex.o src\build\lmathlib.o src\build\lmem.o src\build\loadlib.o src\build\lobject.o src\build\lopcodes.o src\build\loslib.o src\build\lparser.o src\build\lstate.o src\build\lstring.o src\build\lstrlib.o src\build\ltable.o src\build\ltablib.o src\build\ltm.o src\build\lua.o src\build\luac.o src\build\lundump.o src\build\lutf8lib.o src\build\lvm.o src\build\lzio.o src\build\imgui.o src\build\imgui_demo.o src\build\imgui_draw.o src\build\imgui_impl_glfw.o src\build\imgui_impl_opengl3.o src\build\imgui_tables.o src\build\imgui_widgets.o src\build\aabb.o src\build\arena_allocator.o src\build\array.o src\build\bitset.o src\build\body.o src\build\broad_phase.o src\build\constraint_graph.o src\build\contact.o src\build\contact_solver.o src\build\core.o src\build\distance.o src\build\distance_joint.o src\build\dynamic_tree.o src\build\geometry.o src\build\hull.o src\build\id_pool.o src\build\island.o src\build\joint.o src\build\manifold.o src\build\math_functions.o src\build\motor_joint.o src\build\mouse_joint.o src\build\mover.o src\build\prismatic_joint.o src\build\revolute_joint.o src\build\sensor.o src\build\shape.o src\build\solver.o src\build\solver_set.o src\build\table.o src\build\timer.o src\build\types.o src\build\weld_joint.o src\build\wheel_joint.o src\build\world.o -o src\build\app.exe -LC:\msys64\mingw64\lib -lglfw3 -lglew32 -lopengl32 -lgdi32 -lyaml-cpp -lcomdlg32 -lssl -lcrypto
|
[LINK] g++ src\build\Engine.o src\build\main.o src\build\Renderer.o src\build\Components\CameraComponent.o src\build\Components\LightComponent.o src\build\Components\PhysicsComponent.o src\build\Components\ScriptComponent.o src\build\Components\SpriteComponent.o src\build\Components\TextComonent.o src\build\Components\TilemapComponent.o src\build\core\utils\AssetLoader.o src\build\core\utils\EngineConfig.o src\build\core\utils\ExceptionHandler.o src\build\core\utils\FileDialog.o src\build\core\utils\input.o src\build\core\utils\Logging.o src\build\core\utils\Profiler.o src\build\core\utils\utils.o src\build\editor\windows\AssetBrowser.o src\build\editor\windows\Inspector.o src\build\Entitys\Object.o src\build\utils\GameObjectsList.o src\build\utils\Shader.o src\build\utils\UID.o src\build\lapi.o src\build\lauxlib.o src\build\lbaselib.o src\build\lcode.o src\build\lcorolib.o src\build\lctype.o src\build\ldblib.o src\build\ldebug.o src\build\ldo.o src\build\ldump.o src\build\lfunc.o src\build\lgc.o src\build\linit.o src\build\liolib.o src\build\llex.o src\build\lmathlib.o src\build\lmem.o src\build\loadlib.o src\build\lobject.o src\build\lopcodes.o src\build\loslib.o src\build\lparser.o src\build\lstate.o src\build\lstring.o src\build\lstrlib.o src\build\ltable.o src\build\ltablib.o src\build\ltm.o src\build\lua.o src\build\luac.o src\build\lundump.o src\build\lutf8lib.o src\build\lvm.o src\build\lzio.o src\build\imgui.o src\build\imgui_demo.o src\build\imgui_draw.o src\build\imgui_impl_glfw.o src\build\imgui_impl_opengl3.o src\build\imgui_tables.o src\build\imgui_widgets.o src\build\aabb.o src\build\arena_allocator.o src\build\array.o src\build\bitset.o src\build\body.o src\build\broad_phase.o src\build\constraint_graph.o src\build\contact.o src\build\contact_solver.o src\build\core.o src\build\distance.o src\build\distance_joint.o src\build\dynamic_tree.o src\build\geometry.o src\build\hull.o src\build\id_pool.o src\build\island.o src\build\joint.o src\build\manifold.o src\build\math_functions.o src\build\motor_joint.o src\build\mouse_joint.o src\build\mover.o src\build\prismatic_joint.o src\build\revolute_joint.o src\build\sensor.o src\build\shape.o src\build\solver.o src\build\solver_set.o src\build\table.o src\build\timer.o src\build\types.o src\build\weld_joint.o src\build\wheel_joint.o src\build\world.o -o src\build\app.exe -LC:\msys64\mingw64\lib -lglfw3 -lglew32 -lopengl32 -lgdi32 -lyaml-cpp -lcomdlg32 -lssl -lcrypto
|
||||||
[RUN] Executed app.exe successfully.
|
[RUN] Executed app.exe successfully.
|
||||||
|
@ -2,49 +2,48 @@ Engine.DebugLua(true)
|
|||||||
|
|
||||||
local Objects = {}
|
local Objects = {}
|
||||||
local Velocities = {}
|
local Velocities = {}
|
||||||
local CameraObj -- will hold our camera
|
local CachedVecs = {}
|
||||||
local CamSpeed = 800 -- camera speed in world units/sec
|
local CachedPoses = {}
|
||||||
|
local CameraObj
|
||||||
|
local CachedCamPos = nil
|
||||||
|
|
||||||
-- new border extents
|
local CamSpeed = 800
|
||||||
local MinX, MinY = 0, 0
|
local MinX, MinY = 0, 0
|
||||||
local MaxX, MaxY = 5096, 5096
|
local MaxX, MaxY = 5096, 5096
|
||||||
local Speed = 1000 -- light speed in units per second
|
local Speed = 1000
|
||||||
|
|
||||||
-- simple clamp
|
|
||||||
local function clamp(v, lo, hi)
|
local function clamp(v, lo, hi)
|
||||||
if v < lo then return lo end
|
return (v < lo and lo) or (v > hi and hi) or v
|
||||||
if v > hi then return hi end
|
|
||||||
return v
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function OnInit()
|
function OnInit()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
Engine.LogInfo("Initial Speed: " .. Speed)
|
Engine.LogInfo("Initial Speed: " .. Speed)
|
||||||
|
|
||||||
-- cache lights
|
|
||||||
for i = 0, 99 do
|
for i = 0, 99 do
|
||||||
local tag = "Light_" .. i
|
local tag = "Light_" .. i
|
||||||
local obj = Engine.GetObjectByTag(tag)
|
local obj = Engine.GetObjectByTag(tag)
|
||||||
if obj then
|
if obj then
|
||||||
table.insert(Objects, obj)
|
table.insert(Objects, obj)
|
||||||
|
|
||||||
local ang = math.random() * 2 * math.pi
|
local ang = math.random() * 2 * math.pi
|
||||||
local vx = math.cos(ang) * Speed
|
Velocities[obj] = { x = math.cos(ang) * Speed, y = math.sin(ang) * Speed }
|
||||||
local vy = math.sin(ang) * Speed
|
CachedVecs[obj] = Vector2(0, 0) -- reused Vector2 for SetPosition
|
||||||
Velocities[obj] = { x = vx, y = vy }
|
CachedPoses[obj] = obj:GetPosition() -- only once at init
|
||||||
else
|
else
|
||||||
Engine.LogError("Object '" .. tag .. "' not found!")
|
Engine.LogError("Object '" .. tag .. "' not found!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- grab the camera
|
|
||||||
CameraObj = Engine.GetObjectByTag("Camera")
|
CameraObj = Engine.GetObjectByTag("Camera")
|
||||||
if not CameraObj then
|
if CameraObj then
|
||||||
|
CachedCamPos = CameraObj:GetPosition()
|
||||||
|
else
|
||||||
Engine.LogError("Camera object not found!")
|
Engine.LogError("Camera object not found!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function OnUpdate(dt)
|
function OnUpdate(dt)
|
||||||
-- light speed tweaks (same as before)
|
|
||||||
if Engine.KeyDown(Keycode.Equal) or Engine.KeyDown(Keycode.KPAdd) then
|
if Engine.KeyDown(Keycode.Equal) or Engine.KeyDown(Keycode.KPAdd) then
|
||||||
Speed = Speed + 100 * dt
|
Speed = Speed + 100 * dt
|
||||||
Engine.LogInfo(string.format("Speed increased to %.1f", Speed))
|
Engine.LogInfo(string.format("Speed increased to %.1f", Speed))
|
||||||
@ -54,16 +53,10 @@ function OnUpdate(dt)
|
|||||||
Engine.LogInfo(string.format("Speed decreased to %.1f", Speed))
|
Engine.LogInfo(string.format("Speed decreased to %.1f", Speed))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- update light positions
|
||||||
if not CameraObj then
|
|
||||||
Engine.LogError("Camera object not found!")
|
|
||||||
CameraObj = Engine.GetObjectByTag("Camera")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- move lights
|
|
||||||
for _, obj in ipairs(Objects) do
|
for _, obj in ipairs(Objects) do
|
||||||
local vel = Velocities[obj]
|
local vel = Velocities[obj]
|
||||||
local pos = obj:GetPosition()
|
local pos = CachedPoses[obj]
|
||||||
|
|
||||||
local ang = math.atan(vel.y, vel.x)
|
local ang = math.atan(vel.y, vel.x)
|
||||||
vel.x = math.cos(ang) * Speed
|
vel.x = math.cos(ang) * Speed
|
||||||
@ -81,22 +74,30 @@ function OnUpdate(dt)
|
|||||||
ny = clamp(ny, MinY, MaxY)
|
ny = clamp(ny, MinY, MaxY)
|
||||||
end
|
end
|
||||||
|
|
||||||
Velocities[obj] = vel
|
pos.x = nx
|
||||||
obj:SetPosition(Vector2(nx, ny))
|
pos.y = ny
|
||||||
|
|
||||||
|
local cachedVec = CachedVecs[obj]
|
||||||
|
cachedVec.x = nx
|
||||||
|
cachedVec.y = ny
|
||||||
|
obj:SetPosition(cachedVec)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- camera movement
|
||||||
|
if not CameraObj then
|
||||||
|
CameraObj = Engine.GetObjectByTag("Camera")
|
||||||
if CameraObj then
|
if CameraObj then
|
||||||
local camPos = CameraObj:GetPosition()
|
CachedCamPos = CameraObj:GetPosition()
|
||||||
if Engine.KeyDown(Keycode.W) then
|
else
|
||||||
camPos.y = camPos.y - CamSpeed * dt
|
Engine.LogError("Camera object not found!")
|
||||||
elseif Engine.KeyDown(Keycode.S) then
|
return
|
||||||
camPos.y = camPos.y + CamSpeed * dt
|
|
||||||
end
|
end
|
||||||
if Engine.KeyDown(Keycode.A) then
|
|
||||||
camPos.x = camPos.x - CamSpeed * dt
|
|
||||||
elseif Engine.KeyDown(Keycode.D) then
|
|
||||||
camPos.x = camPos.x + CamSpeed * dt
|
|
||||||
end
|
|
||||||
CameraObj:SetPosition(Vector2(camPos.x, camPos.y))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local moved = false
|
||||||
|
if Engine.KeyDown(Keycode.W) then CachedCamPos.y = CachedCamPos.y - CamSpeed * dt moved = true end
|
||||||
|
if Engine.KeyDown(Keycode.S) then CachedCamPos.y = CachedCamPos.y + CamSpeed * dt moved = true end
|
||||||
|
if Engine.KeyDown(Keycode.A) then CachedCamPos.x = CachedCamPos.x - CamSpeed * dt moved = true end
|
||||||
|
if Engine.KeyDown(Keycode.D) then CachedCamPos.x = CachedCamPos.x + CamSpeed * dt moved = true end
|
||||||
|
if moved then CameraObj:SetPosition(CachedCamPos) end
|
||||||
end
|
end
|
||||||
|
@ -1,27 +1,30 @@
|
|||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "Logging.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <json.hpp>
|
#include <json.hpp>
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern float g_fps;
|
extern float g_fps;
|
||||||
extern EngineConfig g_engineConfig;
|
extern EngineConfig g_engineConfig;
|
||||||
|
|
||||||
inline double Lerp(double a, double b, double t) {
|
inline double Lerp(double a, double b, double t)
|
||||||
|
{
|
||||||
return a + (b - a) * t;
|
return a + (b - a) * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SmoothVisualDurations(ProfileNode& node, double blendFactor) {
|
static void SmoothVisualDurations(ProfileNode &node, double blendFactor)
|
||||||
|
{
|
||||||
node.visualStartMs = Lerp(node.visualStartMs, node.startMs, blendFactor);
|
node.visualStartMs = Lerp(node.visualStartMs, node.startMs, blendFactor);
|
||||||
node.visualDurationMs = Lerp(node.visualDurationMs, node.durationMs, blendFactor);
|
node.visualDurationMs = Lerp(node.visualDurationMs, node.durationMs, blendFactor);
|
||||||
for (auto& child : node.children)
|
for (auto &child : node.children)
|
||||||
SmoothVisualDurations(child, blendFactor);
|
SmoothVisualDurations(child, blendFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::BeginFrame() {
|
void HierarchicalProfiler::BeginFrame()
|
||||||
|
{
|
||||||
if (!g_engineConfig.settings.profile_enabled)
|
if (!g_engineConfig.settings.profile_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -43,22 +46,40 @@ void HierarchicalProfiler::BeginFrame() {
|
|||||||
ProfilesLastFrame = 0;
|
ProfilesLastFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::BeginSection(const std::string& name) {
|
void HierarchicalProfiler::BeginSection(const std::string& name)
|
||||||
if (!g_engineConfig.settings.profile_enabled)
|
{
|
||||||
|
if (__builtin_expect(!g_engineConfig.settings.profile_enabled, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto now = Clock::now();
|
if (__builtin_expect(currentStack.size() == 0, 0))
|
||||||
double timeSinceStart = std::chrono::duration<double, std::milli>(now - startTime).count();
|
{
|
||||||
|
static bool warned = false;
|
||||||
|
if (!warned) {
|
||||||
|
Logger::LogWarning("[Profiler] BeginSection called with no active frame (name: %s)", name.c_str());
|
||||||
|
warned = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ProfileNode& parent = *currentStack.back();
|
const auto now = Clock::now();
|
||||||
parent.children.emplace_back(name, timeSinceStart);
|
const double startMs = std::chrono::duration<double, std::milli>(now - startTime).count();
|
||||||
currentStack.push_back(&parent.children.back());
|
|
||||||
|
|
||||||
|
ProfileNode* parent = currentStack.back();
|
||||||
|
parent->children.emplace_back(); // Use default ctor, fill manually
|
||||||
|
ProfileNode& child = parent->children.back();
|
||||||
|
|
||||||
|
child.name = name;
|
||||||
|
child.startMs = startMs;
|
||||||
|
|
||||||
|
currentStack.push_back(&child);
|
||||||
sectionStartTimes.push_back(now);
|
sectionStartTimes.push_back(now);
|
||||||
ProfilesLastFrame++;
|
++ProfilesLastFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::EndSection() {
|
|
||||||
|
|
||||||
|
void HierarchicalProfiler::EndSection()
|
||||||
|
{
|
||||||
if (!g_engineConfig.settings.profile_enabled)
|
if (!g_engineConfig.settings.profile_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -66,7 +87,7 @@ void HierarchicalProfiler::EndSection() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto now = Clock::now();
|
auto now = Clock::now();
|
||||||
ProfileNode& node = *currentStack.back();
|
ProfileNode &node = *currentStack.back();
|
||||||
double duration = std::chrono::duration<double, std::milli>(now - sectionStartTimes.back()).count();
|
double duration = std::chrono::duration<double, std::milli>(now - sectionStartTimes.back()).count();
|
||||||
|
|
||||||
node.durationMs = duration;
|
node.durationMs = duration;
|
||||||
@ -75,28 +96,32 @@ void HierarchicalProfiler::EndSection() {
|
|||||||
sectionStartTimes.pop_back();
|
sectionStartTimes.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::BeginEngineSection(const std::string& name) {
|
void HierarchicalProfiler::BeginEngineSection(const std::string &name)
|
||||||
|
{
|
||||||
if (g_engineConfig.settings.profile_enabled && g_engineConfig.settings.profile_editor)
|
if (g_engineConfig.settings.profile_enabled && g_engineConfig.settings.profile_editor)
|
||||||
BeginSection(name);
|
BeginSection(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::EndEngineSection() {
|
void HierarchicalProfiler::EndEngineSection()
|
||||||
|
{
|
||||||
if (g_engineConfig.settings.profile_enabled && g_engineConfig.settings.profile_editor)
|
if (g_engineConfig.settings.profile_enabled && g_engineConfig.settings.profile_editor)
|
||||||
EndSection();
|
EndSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::BeginDeepSection(const std::string& name) {
|
void HierarchicalProfiler::BeginDeepSection(const std::string &name)
|
||||||
|
{
|
||||||
if (g_engineConfig.settings.profile_deep)
|
if (g_engineConfig.settings.profile_deep)
|
||||||
BeginSection(name);
|
BeginSection(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchicalProfiler::EndDeepSection() {
|
void HierarchicalProfiler::EndDeepSection()
|
||||||
|
{
|
||||||
if (g_engineConfig.settings.profile_deep)
|
if (g_engineConfig.settings.profile_deep)
|
||||||
EndSection();
|
EndSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HierarchicalProfiler::EndFrame()
|
||||||
void HierarchicalProfiler::EndFrame() {
|
{
|
||||||
if (!g_engineConfig.settings.profile_enabled)
|
if (!g_engineConfig.settings.profile_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -113,15 +138,18 @@ void HierarchicalProfiler::EndFrame() {
|
|||||||
frameHistory.erase(frameHistory.begin());
|
frameHistory.erase(frameHistory.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ProfileNode>& HierarchicalProfiler::GetFrames() const {
|
const std::vector<ProfileNode> &HierarchicalProfiler::GetFrames() const
|
||||||
|
{
|
||||||
return frameHistory;
|
return frameHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProfileNode* HierarchicalProfiler::GetLatestFrame() const {
|
const ProfileNode *HierarchicalProfiler::GetLatestFrame() const
|
||||||
|
{
|
||||||
return frameHistory.empty() ? nullptr : &frameHistory.back();
|
return frameHistory.empty() ? nullptr : &frameHistory.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
json SerializeProfileNode(const ProfileNode& node) {
|
json SerializeProfileNode(const ProfileNode &node)
|
||||||
|
{
|
||||||
json j;
|
json j;
|
||||||
j["name"] = node.name;
|
j["name"] = node.name;
|
||||||
j["startMs"] = node.startMs;
|
j["startMs"] = node.startMs;
|
||||||
@ -129,13 +157,11 @@ json SerializeProfileNode(const ProfileNode& node) {
|
|||||||
j["visualStartMs"] = node.visualStartMs;
|
j["visualStartMs"] = node.visualStartMs;
|
||||||
j["visualDurationMs"] = node.visualDurationMs;
|
j["visualDurationMs"] = node.visualDurationMs;
|
||||||
|
|
||||||
for (const auto& child : node.children) {
|
for (const auto &child : node.children)
|
||||||
|
{
|
||||||
j["children"].push_back(SerializeProfileNode(child));
|
j["children"].push_back(SerializeProfileNode(child));
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HierarchicalProfiler profiler;
|
HierarchicalProfiler profiler;
|
||||||
|
Loading…
Reference in New Issue
Block a user