OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Timer.h
Go to the documentation of this file.
1//
2// Class Timer
3// This class is used in IpplTimings.
4//
5// Copyright (c) 2019, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// Implemented as part of the PhD thesis
9// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
21#ifndef TIMER_H
22#define TIMER_H
23
24#include <chrono>
25#include <ctime>
26
27class Timer {
28public:
29 Timer();
30
31 void clear(); // Set all accumulated times to 0
32 void start(); // Start timer
33 void stop(); // Stop timer
34
35 double clock_time(); // Report clock time accumulated in seconds
36 double cpu_time(); // Report total cpu_time which is just user_time + system_time
37
38private:
39 std::chrono::steady_clock::time_point wall_start_m;
40 std::clock_t cpu_start_m;
41
42 double wall_m;
43 double cpu_m;
44};
45
46#endif
Definition Timer.h:27
void start()
Definition Timer.cpp:32
double cpu_m
Definition Timer.h:43
Timer()
Definition Timer.cpp:23
void stop()
Definition Timer.cpp:37
void clear()
Definition Timer.cpp:27
std::clock_t cpu_start_m
Definition Timer.h:40
double wall_m
Definition Timer.h:42
double clock_time()
Definition Timer.cpp:48
double cpu_time()
Definition Timer.cpp:52
std::chrono::steady_clock::time_point wall_start_m
Definition Timer.h:39