OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
ippl
src
Utility
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
23
Timer::Timer
() {
24
this->
clear
();
25
}
26
27
void
Timer::clear
() {
28
wall_m
= 0.0;
29
cpu_m
= 0.0;
30
}
31
32
void
Timer::start
() {
33
wall_start_m
= std::chrono::steady_clock::now();
34
cpu_start_m
= std::clock();
35
}
36
37
void
Timer::stop
() {
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
48
double
Timer::clock_time
() {
49
return
wall_m
;
50
}
51
52
double
Timer::cpu_time
() {
53
return
cpu_m
;
54
}
Timer::start
void start()
Definition
Timer.cpp:32
Timer::cpu_m
double cpu_m
Definition
Timer.h:43
Timer::Timer
Timer()
Definition
Timer.cpp:23
Timer::stop
void stop()
Definition
Timer.cpp:37
Timer::clear
void clear()
Definition
Timer.cpp:27
Timer::cpu_start_m
std::clock_t cpu_start_m
Definition
Timer.h:40
Timer::wall_m
double wall_m
Definition
Timer.h:42
Timer::clock_time
double clock_time()
Definition
Timer.cpp:48
Timer::cpu_time
double cpu_time()
Definition
Timer.cpp:52
Timer::wall_start_m
std::chrono::steady_clock::time_point wall_start_m
Definition
Timer.h:39
Timer.h
Generated on Wed Sep 30 2026 07:14:52 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.8