1 /* $Id: pf_performance_timer.hpp 23640 2011-12-20 17:57:56Z truebrain $ */
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file pf_performance_timer.hpp Performance timer for pathfinders. */
12 #ifndef PF_PERFORMANCE_TIMER_HPP
13 #define PF_PERFORMANCE_TIMER_HPP
17 struct CPerformanceTimer
22 CPerformanceTimer() : m_start(0), m_acc(0) {}
26 m_start
= QueryTime();
31 m_acc
+= QueryTime() - m_start
;
34 inline int Get(int64 coef
)
36 return (int)(m_acc
* coef
/ QueryFrequency());
39 inline int64
QueryTime()
44 inline int64
QueryFrequency()
46 return ((int64
)2200 * 1000000);
52 CPerformanceTimer
*m_pperf
;
54 inline CPerfStartReal(CPerformanceTimer
* perf
) : m_pperf(perf
)
56 if (m_pperf
!= NULL
) m_pperf
->Start();
59 inline ~CPerfStartReal()
66 if (m_pperf
!= NULL
) {
75 inline CPerfStartFake(CPerformanceTimer
* perf
) {}
76 inline ~CPerfStartFake() {}
80 typedef CPerfStartFake CPerfStart
;
82 #endif /* PF_PERFORMANCE_TIMER_HPP */