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 "timer/timer_game_calendar.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_spritegroup.h"
21 * Callback profiler for NewGRF development
23 struct NewGRFProfiler
{
24 NewGRFProfiler(const GRFFile
*grffile
);
27 void BeginResolve(const ResolverObject
&resolver
);
28 void EndResolve(const SpriteGroup
*result
);
29 void RecursiveResolve();
34 std::string
GetOutputFilename() const;
36 static void StartTimer(uint64_t ticks
);
37 static void AbortTimer();
38 static uint32_t FinishAll();
40 /** Measurement of a single sprite group resolution */
42 uint32_t root_sprite
; ///< Pseudo-sprite index in GRF file
43 uint32_t item
; ///< Local ID of item being resolved for
44 uint32_t result
; ///< Result of callback
45 uint32_t subs
; ///< Sub-calls to other sprite groups
46 uint32_t time
; ///< Time taken for resolution (microseconds)
47 uint64_t tick
; ///< Game tick
48 CallbackID cb
; ///< Callback ID
49 GrfSpecFeature feat
; ///< GRF feature being resolved for
52 const GRFFile
*grffile
; ///< Which GRF is being profiled
53 bool active
; ///< Is this profiler collecting data
54 uint64_t start_tick
; ///< Tick number this profiler was started on
55 Call cur_call
; ///< Data for current call in progress
56 std::vector
<Call
> calls
; ///< All calls collected so far
59 extern std::vector
<NewGRFProfiler
> _newgrf_profilers
;
61 #endif /* NEWGRF_PROFILING_H */