Add simple profiler
This commit is contained in:
parent
10f5817c15
commit
371f8e5e6f
|
@ -0,0 +1,48 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHEditorProfiler.h"
|
||||
#include <imgui.h>
|
||||
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "FRC/SHFramerateController.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
SHEditorProfiler::SHEditorProfiler()
|
||||
:SHEditorWindow("Profiler", ImGuiWindowFlags_None)
|
||||
{
|
||||
}
|
||||
|
||||
void SHEditorProfiler::Init()
|
||||
{
|
||||
SHEditorWindow::Init();
|
||||
}
|
||||
|
||||
void SHEditorProfiler::Update()
|
||||
{
|
||||
SHEditorWindow::Update();
|
||||
|
||||
const float dt = static_cast<float>(SHFrameRateController::GetRawDeltaTime());
|
||||
if(frames.size() > MaxFramesDisplayed)
|
||||
{
|
||||
for (size_t i = 1; i < frames.size(); i++)
|
||||
{
|
||||
frames[i-1] = frames[i];
|
||||
}
|
||||
frames[frames.size() - 1] = dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
frames.push_back(dt);
|
||||
}
|
||||
if(Begin())
|
||||
{
|
||||
ImGui::PlotLines("DT", frames.data(), static_cast<int>(frames.size()), 0, nullptr, 0.0f, 16.0f);
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void SHEditorProfiler::Exit()
|
||||
{
|
||||
SHEditorWindow::Exit();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "Editor/EditorWindow/SHEditorWindow.h"
|
||||
#include <vector>
|
||||
constexpr uint32_t MaxFramesDisplayed = 100;
|
||||
namespace SHADE
|
||||
{
|
||||
class SHEditorProfiler final : public SHEditorWindow
|
||||
{
|
||||
public:
|
||||
SHEditorProfiler();
|
||||
void Init() override;
|
||||
void Update() override;
|
||||
void Exit() override;
|
||||
|
||||
private:
|
||||
std::vector<float> frames;
|
||||
};
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "MenuBar/SHEditorMenuBar.h" //Menu Bar
|
||||
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
|
||||
#include "Inspector/SHEditorInspector.h" //Inspector
|
||||
#include "Inspector/SHEditorInspector.h" //Inspector
|
||||
#include "Profiling/SHEditorProfiler.h" //Profiler
|
|
@ -95,6 +95,7 @@ namespace SHADE
|
|||
CreateEditorWindow<SHEditorMenuBar>();
|
||||
CreateEditorWindow<SHHierarchyPanel>();
|
||||
CreateEditorWindow<SHEditorInspector>();
|
||||
CreateEditorWindow<SHEditorProfiler>();
|
||||
|
||||
SHLOG_INFO("Successfully initialised SHADE Engine Editor")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue