forked from mirror/OpenTTD
Feature: NewGRF callback profiling (#7868)
Adds a console command newgrf_profile to collect some profiling data about NewGRF action 2 callbacks and produce a CSV file.
This commit is contained in:
committed by
GitHub
parent
f88ac83408
commit
c8779fb311
@@ -11,6 +11,7 @@
|
||||
#include <algorithm>
|
||||
#include "debug.h"
|
||||
#include "newgrf_spritegroup.h"
|
||||
#include "newgrf_profiling.h"
|
||||
#include "core/pool_func.hpp"
|
||||
|
||||
#include "safeguards.h"
|
||||
@@ -34,10 +35,23 @@ TemporaryStorageArray<int32, 0x110> _temp_store;
|
||||
/* static */ const SpriteGroup *SpriteGroup::Resolve(const SpriteGroup *group, ResolverObject &object, bool top_level)
|
||||
{
|
||||
if (group == nullptr) return nullptr;
|
||||
if (top_level) {
|
||||
|
||||
const GRFFile *grf = object.grffile;
|
||||
auto profiler = std::find_if(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](const NewGRFProfiler &pr) { return pr.grffile == grf; });
|
||||
|
||||
if (profiler == _newgrf_profilers.end() || !profiler->active) {
|
||||
if (top_level) _temp_store.ClearChanges();
|
||||
return group->Resolve(object);
|
||||
} else if (top_level) {
|
||||
profiler->BeginResolve(object);
|
||||
_temp_store.ClearChanges();
|
||||
const SpriteGroup *result = group->Resolve(object);
|
||||
profiler->EndResolve(result);
|
||||
return result;
|
||||
} else {
|
||||
profiler->RecursiveResolve();
|
||||
return group->Resolve(object);
|
||||
}
|
||||
return group->Resolve(object);
|
||||
}
|
||||
|
||||
RealSpriteGroup::~RealSpriteGroup()
|
||||
|
Reference in New Issue
Block a user