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 pf_performance_timer.hpp Performance timer for pathfinders. */
10 #ifndef PF_PERFORMANCE_TIMER_HPP
11 #define PF_PERFORMANCE_TIMER_HPP
15 struct CPerformanceTimer
20 CPerformanceTimer() : m_start(0), m_acc(0) {}
24 m_start
= QueryTime();
29 m_acc
+= QueryTime() - m_start
;
32 inline int Get(int64 coef
)
34 return (int)(m_acc
* coef
/ QueryFrequency());
37 inline int64
QueryTime()
42 inline int64
QueryFrequency()
44 return ((int64
)2200 * 1000000);
50 CPerformanceTimer
*m_pperf
;
52 inline CPerfStartReal(CPerformanceTimer
& perf
) : m_pperf(&perf
)
54 if (m_pperf
!= nullptr) m_pperf
->Start();
57 inline ~CPerfStartReal()
64 if (m_pperf
!= nullptr) {
73 inline CPerfStartFake(CPerformanceTimer
& perf
) {}
74 inline ~CPerfStartFake() {}
78 typedef CPerfStartFake CPerfStart
;
80 #endif /* PF_PERFORMANCE_TIMER_HPP */