OpenTTD Source  1.11.2
newgrf_profiling.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef NEWGRF_PROFILING_H
11 #define NEWGRF_PROFILING_H
12 
13 #include "stdafx.h"
14 #include "date_type.h"
15 #include "newgrf.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_spritegroup.h"
18 
19 #include <vector>
20 #include <string>
21 #include <memory>
22 
29 
30  void BeginResolve(const ResolverObject &resolver);
31  void EndResolve(const SpriteGroup *result);
32  void RecursiveResolve();
33 
34  void Start();
35  uint32 Finish();
36  void Abort();
37  std::string GetOutputFilename() const;
38 
39  static uint32 FinishAll();
40 
42  struct Call {
43  uint32 root_sprite;
44  uint32 item;
45  uint32 result;
46  uint32 subs;
47  uint32 time;
48  uint16 tick;
51  };
52 
53  const GRFFile *grffile;
54  bool active;
55  uint16 start_tick;
57  std::vector<Call> calls;
58 };
59 
60 extern std::vector<NewGRFProfiler> _newgrf_profilers;
61 extern Date _newgrf_profile_end_date;
62 
63 #endif /* NEWGRF_PROFILING_H */
NewGRFProfiler::calls
std::vector< Call > calls
All calls collected so far.
Definition: newgrf_profiling.h:57
NewGRFProfiler::Call::tick
uint16 tick
Game tick.
Definition: newgrf_profiling.h:48
NewGRFProfiler::grffile
const GRFFile * grffile
Which GRF is being profiled.
Definition: newgrf_profiling.h:53
NewGRFProfiler::Call
Measurement of a single sprite group resolution.
Definition: newgrf_profiling.h:42
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:315
NewGRFProfiler::RecursiveResolve
void RecursiveResolve()
Capture a recursive sprite group resolution.
Definition: newgrf_profiling.cpp:81
newgrf_callbacks.h
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition: newgrf_callbacks.h:20
NewGRFProfiler::NewGRFProfiler
NewGRFProfiler(const GRFFile *grffile)
Create profiler object and begin profiling session.
Definition: newgrf_profiling.cpp:30
NewGRFProfiler::EndResolve
void EndResolve(const SpriteGroup *result)
Capture the completion of a sprite group resolution.
Definition: newgrf_profiling.cpp:60
NewGRFProfiler::BeginResolve
void BeginResolve(const ResolverObject &resolver)
Capture the start of a sprite group resolution.
Definition: newgrf_profiling.cpp:45
NewGRFProfiler::~NewGRFProfiler
~NewGRFProfiler()
Complete profiling session and write data to file.
Definition: newgrf_profiling.cpp:37
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
NewGRFProfiler::Call::feat
GrfSpecFeature feat
GRF feature being resolved for.
Definition: newgrf_profiling.h:50
NewGRFProfiler::Call::result
uint32 result
Result of callback.
Definition: newgrf_profiling.h:45
NewGRFProfiler::Call::item
uint32 item
Local ID of item being resolved for.
Definition: newgrf_profiling.h:44
NewGRFProfiler::GetOutputFilename
std::string GetOutputFilename() const
Get name of the file that will be written.
Definition: newgrf_profiling.cpp:131
NewGRFProfiler::Call::subs
uint32 subs
Sub-calls to other sprite groups.
Definition: newgrf_profiling.h:46
NewGRFProfiler::active
bool active
Is this profiler collecting data.
Definition: newgrf_profiling.h:54
stdafx.h
NewGRFProfiler::cur_call
Call cur_call
Data for current call in progress.
Definition: newgrf_profiling.h:56
date_type.h
newgrf_spritegroup.h
GrfSpecFeature
GrfSpecFeature
Definition: newgrf.h:66
NewGRFProfiler
Callback profiler for NewGRF development.
Definition: newgrf_profiling.h:26
NewGRFProfiler::start_tick
uint16 start_tick
Tick number this profiler was started on.
Definition: newgrf_profiling.h:55
newgrf.h
NewGRFProfiler::Call::root_sprite
uint32 root_sprite
Pseudo-sprite index in GRF file.
Definition: newgrf_profiling.h:43
NewGRFProfiler::Call::time
uint32 time
Time taken for resolution (microseconds)
Definition: newgrf_profiling.h:47
SpriteGroup
Definition: newgrf_spritegroup.h:57
NewGRFProfiler::Call::cb
CallbackID cb
Callback ID.
Definition: newgrf_profiling.h:49
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105