1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-28 17:24:47 +01:00

Implement profiler (#16194)

* Implement profiling API

* Add console commands for the profiler

* Remove accidental line

* Correct csv output

* Add copyright notice

* Add missing override

* Add default virtual destructor

* Explicitly pass template argument

* Use static

* Add plugin API for profiler

* Add more profile calls

* Workaround for GCC hopefully

* Add missing static keyword

* Use uint64 for call count

* Reduce name length see if CI passes

* Improve handling of function names

* Work around (broken) static inline variables

* Fix missing include

* Disable profiler for clang 5 and older

* Update copyright date

* Profile UpdateAllMiscEntities

* Apply review suggestions

Co-authored-by: Ted John <ted@brambles.org>
This commit is contained in:
ζeh Matt
2022-01-18 10:21:20 -08:00
committed by GitHub
parent e78704f48f
commit 993b168bfd
28 changed files with 678 additions and 8 deletions

View File

@@ -27,6 +27,7 @@
#include "management/NewsItem.h"
#include "network/network.h"
#include "platform/Platform2.h"
#include "profiling/Profiling.h"
#include "ride/Vehicle.h"
#include "scenario/Scenario.h"
#include "scripting/ScriptEngine.h"
@@ -55,6 +56,8 @@ GameState::GameState()
*/
void GameState::InitAll(int32_t mapSize)
{
PROFILED_FUNCTION();
gInMapInitCode = true;
gCurrentTicks = 0;
@@ -93,6 +96,8 @@ void GameState::InitAll(int32_t mapSize)
*/
void GameState::Tick()
{
PROFILED_FUNCTION();
gInUpdateCode = true;
// Normal game play will update only once every GAME_UPDATE_TIME_MS
@@ -241,6 +246,8 @@ void GameState::Tick()
void GameState::UpdateLogic(LogicTimings* timings)
{
PROFILED_FUNCTION();
auto start_time = std::chrono::high_resolution_clock::now();
auto report_time = [timings, start_time](LogicTimePart part) {
@@ -386,6 +393,8 @@ void GameState::UpdateLogic(LogicTimings* timings)
void GameState::CreateStateSnapshot()
{
PROFILED_FUNCTION();
IGameStateSnapshots* snapshots = GetContext()->GetGameStateSnapshots();
auto& snapshot = snapshots->CreateSnapshot();