Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ProfileTimer.inl
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#ifndef DVD_CORE_TIME_PROFILE_TIMER_INL_
33#define DVD_CORE_TIME_PROFILE_TIMER_INL_
34
35namespace Divide {
36namespace Time {
37
38inline U64 ProfileTimer::get() const
39{
40 if (_timerAverage == 0) {
41 return getChildTotal();
42 }
43
44 return _timerAverage / std::max(_timerCounter, 1u);
45}
46
47inline const string& ProfileTimer::name() const noexcept
48{
49 return _name;
50}
51
52inline ProfileTimer& ADD_TIMER(const char* timerName)
53{
54 return ProfileTimer::getNewTimer(timerName);
55}
56
57inline void START_TIMER(ProfileTimer& timer) noexcept
58{
59 timer.start();
60}
61
62inline void STOP_TIMER(ProfileTimer& timer) noexcept
63{
64 timer.stop();
65}
66
67inline string PRINT_TIMER(const ProfileTimer& timer)
68{
69 return timer.print();
70}
71
72inline U64 QUERY_TIMER( const ProfileTimer& timer ) noexcept
73{
74 return timer.get();
75}
76
77inline void REMOVE_TIMER(ProfileTimer*& timer)
78{
80 timer = nullptr;
81}
82
83} // namespace Time
84} // namespace Divide
85
86#endif //DVD_CORE_TIME_PROFILE_TIMER_INL_
static void removeTimer(ProfileTimer &timer)
static ProfileTimer & getNewTimer(const char *timerName)
string print(U32 level=0) const
const string & name() const noexcept
void REMOVE_TIMER(ProfileTimer *&timer)
U64 QUERY_TIMER(const ProfileTimer &timer) noexcept
void START_TIMER(ProfileTimer &timer) noexcept
ProfileTimer & ADD_TIMER(const char *timerName)
void STOP_TIMER(ProfileTimer &timer) noexcept
string PRINT_TIMER(ProfileTimer &timer)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint64_t U64