Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ProfileTimer.h
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#pragma once
33#ifndef DVD_CORE_TIME_PROFILE_TIMER_H_
34#define DVD_CORE_TIME_PROFILE_TIMER_H_
35
36namespace Divide {
37namespace Time {
38
39class ApplicationTimer;
41 public:
42 ProfileTimer() = default;
43
44 void start() noexcept;
45 void stop() noexcept;
46 void reset() noexcept;
47 [[nodiscard]] string print(U32 level = 0) const;
48
49 [[nodiscard]] U64 get() const;
50 [[nodiscard]] U64 getChildTotal() const;
51 [[nodiscard]] const string& name() const noexcept;
52
53 static string printAll();
54 static ProfileTimer& getNewTimer(const char* timerName);
55 static void removeTimer(ProfileTimer& timer);
56
57 static U64 overhead();
58
59 // time data
60 protected:
61 string _name = "";
62 U64 _timer = 0UL;
66
67 // timer <-> timer relationship
68 public:
69 void addChildTimer(ProfileTimer& child);
70 void removeChildTimer(ProfileTimer& child);
71
72 bool hasChildTimer(const ProfileTimer& child) const;
73
74 protected:
76 U32 _parent = Config::Profile::MAX_PROFILE_TIMERS + 1;
77};
78
79class ScopedTimer final : NonCopyable {
80public:
81 explicit ScopedTimer(ProfileTimer& timer) noexcept;
83
84private:
86};
87
88ProfileTimer& ADD_TIMER(const char* timerName);
89void REMOVE_TIMER(ProfileTimer*& timer);
90
91void START_TIMER(ProfileTimer& timer) noexcept;
92void STOP_TIMER(ProfileTimer& timer) noexcept;
93U64 QUERY_TIMER(const ProfileTimer& timer) noexcept;
94
96
97} // namespace Time
98} // namespace Divide
99
100#endif //DVD_CORE_TIME_PROFILE_TIMER_H_
101
102#include "ProfileTimer.inl"
void removeChildTimer(ProfileTimer &child)
void addChildTimer(ProfileTimer &child)
static void removeTimer(ProfileTimer &timer)
static ProfileTimer & getNewTimer(const char *timerName)
string print(U32 level=0) const
const string & name() const noexcept
bool hasChildTimer(const ProfileTimer &child) const
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
eastl::vector< Type > vector
Definition: Vector.h:42
uint32_t U32
uint64_t U64