GDB (xrefs)

run-time-clock.h
Go to the documentation of this file.
1 /* User/system CPU time clocks that follow the std::chrono interface.
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef RUN_TIME_CLOCK_H
20 #define RUN_TIME_CLOCK_H
21
22 #include <chrono>
23
24 /* Count the total amount of time spent executing in user mode. */
25
26 struct user_cpu_time_clock
27 {
28 using duration = std::chrono::microseconds;
29 using rep = duration::rep;
30 using period = duration::period;
31 using time_point = std::chrono::time_point<user_cpu_time_clock>;
32
33 static constexpr bool is_steady = true;
34
35 /* Use run_time_clock::now instead. */
36 static time_point now () noexcept = delete;
37 };
38
39 /* Count the total amount of time spent executing in kernel mode. */
40
41 struct system_cpu_time_clock
42 {
43 using duration = std::chrono::microseconds;
44 using rep = duration::rep;
45 using period = duration::period;
46 using time_point = std::chrono::time_point<system_cpu_time_clock>;
47
48 static constexpr bool is_steady = true;
49
50 /* Use run_time_clock::now instead. */
51 static time_point now () noexcept = delete;
52 };
53
54 /* Count the total amount of time spent executing in userspace+kernel
55 mode. */
56
57 struct run_time_clock
58 {
59 using duration = std::chrono::microseconds;
60 using rep = duration::rep;
61 using period = duration::period;
62 using time_point = std::chrono::time_point<run_time_clock>;
63
64 static constexpr bool is_steady = true;
65
66 static time_point now () noexcept;
67
68 /* Return the user/system time as separate time points, if
69 supported. If not supported, then the combined user+kernel time
70 is returned in USER and SYSTEM is set to zero. */
71 static void now (user_cpu_time_clock::time_point &user,
72 system_cpu_time_clock::time_point &system) noexcept;
73 };
74
75 #endif
user_cpu_time_clock
Definition: run-time-clock.h:26
run_time_clock::period
duration::period period
Definition: run-time-clock.h:61
run_time_clock
Definition: run-time-clock.h:57
system_cpu_time_clock::time_point
std::chrono::time_point< system_cpu_time_clock > time_point
Definition: run-time-clock.h:46
system_cpu_time_clock
Definition: run-time-clock.h:41
user_cpu_time_clock::now
static time_point now() noexcept=delete
user_cpu_time_clock::is_steady
static constexpr bool is_steady
Definition: run-time-clock.h:33
system_cpu_time_clock::period
duration::period period
Definition: run-time-clock.h:45
user_cpu_time_clock::duration
std::chrono::microseconds duration
Definition: run-time-clock.h:28
run_time_clock::duration
std::chrono::microseconds duration
Definition: run-time-clock.h:59
user_cpu_time_clock::time_point
std::chrono::time_point< user_cpu_time_clock > time_point
Definition: run-time-clock.h:31
user_cpu_time_clock::period
duration::period period
Definition: run-time-clock.h:30
run_time_clock::time_point
std::chrono::time_point< run_time_clock > time_point
Definition: run-time-clock.h:62
run_time_clock::rep
duration::rep rep
Definition: run-time-clock.h:60
system_cpu_time_clock::duration
std::chrono::microseconds duration
Definition: run-time-clock.h:43
user_cpu_time_clock::rep
duration::rep rep
Definition: run-time-clock.h:29
system_cpu_time_clock::rep
duration::rep rep
Definition: run-time-clock.h:44