GDBserver
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 
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 
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 
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
duration::period period
std::chrono::time_point< system_cpu_time_clock > time_point
static time_point now() noexcept=delete
static constexpr bool is_steady
duration::period period
std::chrono::microseconds duration
std::chrono::microseconds duration
std::chrono::time_point< user_cpu_time_clock > time_point
duration::period period
std::chrono::time_point< run_time_clock > time_point
duration::rep rep
std::chrono::microseconds duration
duration::rep rep