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/>.
8 /** @file newgrf_profiling.h Profiling of NewGRF action 2 handling. */
10 #ifndef NEWGRF_PROFILING_H
11 #define NEWGRF_PROFILING_H
14 #include "date_type.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_spritegroup.h"
24 * Callback profiler for NewGRF development
26 struct NewGRFProfiler
{
27 NewGRFProfiler(const GRFFile
*grffile
);
30 void BeginResolve(const ResolverObject
&resolver
);
31 void EndResolve(const SpriteGroup
*result
);
32 void RecursiveResolve();
37 std::string
GetOutputFilename() const;
39 static uint32
FinishAll();
41 /** Measurement of a single sprite group resolution */
43 uint32 root_sprite
; ///< Pseudo-sprite index in GRF file
44 uint32 item
; ///< Local ID of item being resolved for
45 uint32 result
; ///< Result of callback
46 uint32 subs
; ///< Sub-calls to other sprite groups
47 uint32 time
; ///< Time taken for resolution (microseconds)
48 uint16 tick
; ///< Game tick
49 CallbackID cb
; ///< Callback ID
50 GrfSpecFeature feat
; ///< GRF feature being resolved for
53 const GRFFile
*grffile
; ///< Which GRF is being profiled
54 bool active
; ///< Is this profiler collecting data
55 uint16 start_tick
; ///< Tick number this profiler was started on
56 Call cur_call
; ///< Data for current call in progress
57 std::vector
<Call
> calls
; ///< All calls collected so far
60 extern std::vector
<NewGRFProfiler
> _newgrf_profilers
;
61 extern Date _newgrf_profile_end_date
;
63 #endif /* NEWGRF_PROFILING_H */