OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Timer.cpp
Go to the documentation of this file.
1 //
2 // Class Timer
3 // This class is used in IpplTimings.
4 // https://www.boost.org/doc/libs/1_70_0/libs/timer/doc/cpu_timers.html
5 //
6 // Copyright (c) 2019, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // Implemented as part of the PhD thesis
10 // "Precise Simulations of Multibunches in High Intensity Cyclotrons"
11 //
12 // This file is part of OPAL.
13 //
14 // OPAL is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21 //
22 #include "Timer.h"
23 
25  this->clear();
26 }
27 
28 
29 void Timer::clear() {
30  wall_m = user_m = sys_m = 0.0;
31 }
32 
33 
34 void Timer::start() {
35  timer_m.start();
36 }
37 
38 
39 void Timer::stop() {
40  timer_m.stop();
41 
42  boost::timer::cpu_times elapsed = timer_m.elapsed();
43 
44  wall_m += elapsed.wall;
45  user_m += elapsed.user;
46  sys_m += elapsed.system;
47 }
48 
49 
51  return wall_m * 1.0e-9;
52 }
53 
54 
55 double Timer::user_time() {
56  return user_m * 1.0e-9;
57 }
58 
59 
61  return sys_m * 1.0e-9;
62 }
63 
64 
65 double Timer::cpu_time() {
66  return (user_m + sys_m) * 1.0e-9;
67 }
boost::timer::cpu_timer timer_m
Definition: Timer.h:46
void start()
Definition: Timer.cpp:34
double user_time()
Definition: Timer.cpp:55
Timer()
Definition: Timer.cpp:24
void stop()
Definition: Timer.cpp:39
void clear()
Definition: Timer.cpp:29
double wall_m
Definition: Timer.h:43
double clock_time()
Definition: Timer.cpp:50
double user_m
Definition: Timer.h:44
double cpu_time()
Definition: Timer.cpp:65
double system_time()
Definition: Timer.cpp:60
double sys_m
Definition: Timer.h:45