OpenTTD Source 20260206-master-g4d4e37dbf1
NewGRFProfiler Struct Reference

Callback profiler for NewGRF development. More...

#include <newgrf_profiling.h>

Data Structures

struct  Call
 Measurement of a single sprite group resolution. More...

Public Member Functions

 NewGRFProfiler (const GRFFile *grffile)
 Create profiler object and begin profiling session.
 ~NewGRFProfiler ()
 Complete profiling session and write data to file.
void BeginResolve (const ResolverObject &resolver)
 Capture the start of a sprite group resolution.
void EndResolve (const ResolverResult &result)
 Capture the completion of a sprite group resolution.
void RecursiveResolve ()
 Capture a recursive sprite group resolution.
void Start ()
uint32_t Finish ()
void Abort ()
std::string GetOutputFilename () const
 Get name of the file that will be written.

Static Public Member Functions

static void StartTimer (uint64_t ticks)
 Start the timeout timer that will finish all profiling sessions.
static void AbortTimer ()
 Abort the timeout timer, so the timer callback is never called.
static uint32_t FinishAll ()

Data Fields

const GRFFilegrffile = nullptr
 Which GRF is being profiled.
bool active = false
 Is this profiler collecting data.
uint64_t start_tick = 0
 Tick number this profiler was started on.
Call cur_call {}
 Data for current call in progress.
std::vector< Callcalls {}
 All calls collected so far.

Detailed Description

Callback profiler for NewGRF development.

Definition at line 22 of file newgrf_profiling.h.

Constructor & Destructor Documentation

◆ NewGRFProfiler()

NewGRFProfiler::NewGRFProfiler ( const GRFFile * grffile)

Create profiler object and begin profiling session.

Parameters
grffileThe GRF file to collect profiling data on

Definition at line 32 of file newgrf_profiling.cpp.

References grffile.

◆ ~NewGRFProfiler()

NewGRFProfiler::~NewGRFProfiler ( )

Complete profiling session and write data to file.

Definition at line 39 of file newgrf_profiling.cpp.

Member Function Documentation

◆ Abort()

void NewGRFProfiler::Abort ( )

Definition at line 141 of file newgrf_profiling.cpp.

◆ AbortTimer()

void NewGRFProfiler::AbortTimer ( )
static

Abort the timeout timer, so the timer callback is never called.

Definition at line 195 of file newgrf_profiling.cpp.

References _profiling_finish_timeout.

◆ BeginResolve()

void NewGRFProfiler::BeginResolve ( const ResolverObject & resolver)

Capture the start of a sprite group resolution.

Parameters
resolverData about sprite group being resolved

Definition at line 47 of file newgrf_profiling.cpp.

References ResolverObject::callback, TimerGameTick::counter, cur_call, ResolverObject::GetDebugID(), ResolverObject::GetFeature(), and ResolverObject::root_spritegroup.

◆ EndResolve()

void NewGRFProfiler::EndResolve ( const ResolverResult & result)

Capture the completion of a sprite group resolution.

Definition at line 62 of file newgrf_profiling.cpp.

References calls, cur_call, and GetSpriteLocalID().

◆ Finish()

uint32_t NewGRFProfiler::Finish ( )

Definition at line 109 of file newgrf_profiling.cpp.

◆ FinishAll()

uint32_t NewGRFProfiler::FinishAll ( )
static

Definition at line 156 of file newgrf_profiling.cpp.

◆ GetOutputFilename()

std::string NewGRFProfiler::GetOutputFilename ( ) const

Get name of the file that will be written.

Returns
File name of profiling output file.

Definition at line 151 of file newgrf_profiling.cpp.

References FiosGetScreenshotDir(), and grffile.

◆ RecursiveResolve()

void NewGRFProfiler::RecursiveResolve ( )

Capture a recursive sprite group resolution.

Definition at line 97 of file newgrf_profiling.cpp.

References cur_call.

◆ Start()

void NewGRFProfiler::Start ( )

Definition at line 102 of file newgrf_profiling.cpp.

◆ StartTimer()

void NewGRFProfiler::StartTimer ( uint64_t ticks)
static

Start the timeout timer that will finish all profiling sessions.

Definition at line 187 of file newgrf_profiling.cpp.

References _profiling_finish_timeout, and TimerGameTick::None.

Field Documentation

◆ active

bool NewGRFProfiler::active = false

Is this profiler collecting data.

Definition at line 52 of file newgrf_profiling.h.

◆ calls

std::vector<Call> NewGRFProfiler::calls {}

All calls collected so far.

Definition at line 55 of file newgrf_profiling.h.

Referenced by EndResolve().

◆ cur_call

Call NewGRFProfiler::cur_call {}

Data for current call in progress.

Definition at line 54 of file newgrf_profiling.h.

Referenced by BeginResolve(), EndResolve(), and RecursiveResolve().

◆ grffile

const GRFFile* NewGRFProfiler::grffile = nullptr

Which GRF is being profiled.

Definition at line 51 of file newgrf_profiling.h.

Referenced by GetOutputFilename(), NewGRFProfiler(), and SpriteGroup::Resolve().

◆ start_tick

uint64_t NewGRFProfiler::start_tick = 0

Tick number this profiler was started on.

Definition at line 53 of file newgrf_profiling.h.


The documentation for this struct was generated from the following files: