OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Timer.cpp
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#include "Timer.h"
22
24 this->clear();
25}
26
28 wall_m = 0.0;
29 cpu_m = 0.0;
30}
31
33 wall_start_m = std::chrono::steady_clock::now();
34 cpu_start_m = std::clock();
35}
36
38 const auto wall_end = std::chrono::steady_clock::now();
39 const auto cpu_end = std::clock();
40
41 wall_m += std::chrono::duration<double>(
42 wall_end - wall_start_m).count();
43
44 cpu_m += static_cast<double>(cpu_end - cpu_start_m) /
45 CLOCKS_PER_SEC;
46}
47
49 return wall_m;
50}
51
53 return cpu_m;
54}
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