1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-25 07:44:38 +01:00

Provide more detailed stats about simulation performance

This commit is contained in:
Michał Janiszewski
2020-08-29 22:47:37 +02:00
parent a3312547ae
commit 0410b37369
3 changed files with 125 additions and 4 deletions

View File

@@ -12,6 +12,7 @@
#include "Context.h"
#include "Editor.h"
#include "Game.h"
#include "GameState.h"
#include "GameStateSnapshots.h"
#include "Input.h"
#include "OpenRCT2.h"
@@ -37,6 +38,7 @@
#include "world/Scenery.h"
#include <algorithm>
#include <chrono>
using namespace OpenRCT2;
using namespace OpenRCT2::Scripting;
@@ -225,8 +227,17 @@ void GameState::Update()
gInUpdateCode = false;
}
void GameState::UpdateLogic()
void GameState::UpdateLogic(LogicTimings* timings)
{
auto start_time = std::chrono::high_resolution_clock::now();
auto report_time = [timings, start_time](LogicTimePart part) {
if (timings != nullptr)
{
timings->TimingInfo[part][timings->CurrentIdx] = std::chrono::high_resolution_clock::now() - start_time;
}
};
gScreenAge++;
if (gScreenAge == 0)
gScreenAge--;
@@ -234,6 +245,7 @@ void GameState::UpdateLogic()
GetContext()->GetReplayManager()->Update();
network_update();
report_time(LogicTimePart::NetworkUpdate);
if (network_get_mode() == NETWORK_MODE_SERVER)
{
@@ -277,33 +289,51 @@ void GameState::UpdateLogic()
date_update();
_date = Date(static_cast<uint32_t>(gDateMonthsElapsed), gDateMonthTicks);
report_time(LogicTimePart::Date);
scenario_update();
report_time(LogicTimePart::Scenario);
climate_update();
report_time(LogicTimePart::Climate);
map_update_tiles();
report_time(LogicTimePart::MapTiles);
// Temporarily remove provisional paths to prevent peep from interacting with them
map_remove_provisional_elements();
report_time(LogicTimePart::MapStashProvisionalElements);
map_update_path_wide_flags();
report_time(LogicTimePart::MapPathWideFlags);
peep_update_all();
report_time(LogicTimePart::Peep);
map_restore_provisional_elements();
report_time(LogicTimePart::MapRestoreProvisionalElements);
vehicle_update_all();
report_time(LogicTimePart::Vehicle);
sprite_misc_update_all();
report_time(LogicTimePart::Misc);
Ride::UpdateAll();
report_time(LogicTimePart::Ride);
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
{
_park->Update(_date);
}
report_time(LogicTimePart::Park);
research_update();
report_time(LogicTimePart::Research);
ride_ratings_update_all();
report_time(LogicTimePart::RideRatings);
ride_measurements_update();
report_time(LogicTimePart::RideMeasurments);
News::UpdateCurrentItem();
report_time(LogicTimePart::News);
map_animation_invalidate_all();
report_time(LogicTimePart::MapAnimation);
vehicle_sounds_update();
peep_update_crowd_noise();
climate_update_sound();
report_time(LogicTimePart::Sounds);
editor_open_windows_for_current_step();
// Update windows
@@ -316,9 +346,11 @@ void GameState::UpdateLogic()
}
GameActions::ProcessQueue();
report_time(LogicTimePart::GameActions);
network_process_pending();
network_flush();
report_time(LogicTimePart::NetworkFlush);
gCurrentTicks++;
gScenarioTicks++;
@@ -332,7 +364,13 @@ void GameState::UpdateLogic()
{
hookEngine.Call(HOOK_TYPE::INTERVAL_DAY, true);
}
report_time(LogicTimePart::Scripts);
#endif
if (timings != nullptr)
{
timings->CurrentIdx = (timings->CurrentIdx + 1) % LOGIC_UPDATE_MEASURMENTS_COUNT;
}
}
void GameState::CreateStateSnapshot()