OpenTTD Source  1.10.0-RC1
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 */
Interface for SpriteGroup-s to access the gamestate.
~NewGRFProfiler()
Complete profiling session and write data to file.
Measurement of a single sprite group resolution.
uint16 tick
Game tick.
Call cur_call
Data for current call in progress.
std::vector< Call > calls
All calls collected so far.
Callbacks that NewGRFs could implement.
void EndResolve(const SpriteGroup *result)
Capture the completion of a sprite group resolution.
GrfSpecFeature
Definition: newgrf.h:66
uint32 item
Local ID of item being resolved for.
Action 2 handling.
GrfSpecFeature feat
GRF feature being resolved for.
void RecursiveResolve()
Capture a recursive sprite group resolution.
uint32 subs
Sub-calls to other sprite groups.
Definition of base types and functions in a cross-platform compatible way.
uint32 result
Result of callback.
void BeginResolve(const ResolverObject &resolver)
Capture the start of a sprite group resolution.
Callback profiler for NewGRF development.
const GRFFile * grffile
Which GRF is being profiled.
uint16 start_tick
Tick number this profiler was started on.
std::string GetOutputFilename() const
Get name of the file that will be written.
NewGRFProfiler(const GRFFile *grffile)
Create profiler object and begin profiling session.
uint32 time
Time taken for resolution (microseconds)
bool active
Is this profiler collecting data.
Types related to the dates in OpenTTD.
int32 Date
The type to store our dates in.
Definition: date_type.h:14
CallbackID
List of implemented NewGRF callbacks.
CallbackID cb
Callback ID.
uint32 root_sprite
Pseudo-sprite index in GRF file.
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
Base for the NewGRF implementation.