cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
TimeKeeper.h
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2020-2024 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef CepGen_Utils_TimeKeeper_h
20
#define CepGen_Utils_TimeKeeper_h
21
22
#include <string>
23
#include <unordered_map>
24
#include <vector>
25
26
#include "
CepGen/Utils/Timer.h
"
27
28
#define CG_CONCAT(a, b) a##b
29
#define CG_TICKER_NAME(a, b) CG_CONCAT(a, b)
30
#define CG_TICKER(tmr) utils::TimeKeeper::Ticker CG_TICKER_NAME(ticker, __COUNTER__)(tmr, __PRETTY_FUNCTION__)
31
32
namespace
cepgen
{
33
namespace
utils {
35
class
TimeKeeper
{
36
public
:
37
explicit
TimeKeeper
() =
default
;
38
39
void
clear
();
40
bool
empty
()
const
{
return
monitors_.empty(); }
41
std::string
summary
()
const
;
42
46
TimeKeeper
&
tick
(
const
std::string& func,
double
time = -1.);
47
48
const
Timer
&
timer
()
const
;
49
51
class
Ticker
{
52
public
:
53
explicit
Ticker
(
TimeKeeper
*,
const
std::string&);
54
~Ticker
();
55
56
private
:
57
TimeKeeper
* tk_{
nullptr
};
58
std::string name_;
59
Timer
tmr_;
60
};
61
62
private
:
63
std::unordered_map<std::string, std::vector<float> > monitors_;
64
Timer
tmr_;
65
};
66
}
// namespace utils
67
}
// namespace cepgen
68
69
#endif
Timer.h
cepgen::utils::TimeKeeper::Ticker
Scoped timekeeping utility.
Definition
TimeKeeper.h:51
cepgen::utils::TimeKeeper::Ticker::~Ticker
~Ticker()
Ticker destructor to store the timing information to the parent timekeeper.
Definition
TimeKeeper.cpp:84
cepgen::utils::TimeKeeper
Collection of clocks to benchmark execution blocks.
Definition
TimeKeeper.h:35
cepgen::utils::TimeKeeper::empty
bool empty() const
Check if at least one monitor recorded something.
Definition
TimeKeeper.h:40
cepgen::utils::TimeKeeper::tick
TimeKeeper & tick(const std::string &func, double time=-1.)
Count the time for one monitor.
Definition
TimeKeeper.cpp:32
cepgen::utils::TimeKeeper::timer
const Timer & timer() const
Local timer object.
cepgen::utils::TimeKeeper::TimeKeeper
TimeKeeper()=default
cepgen::utils::TimeKeeper::summary
std::string summary() const
Write a summary of all monitors.
Definition
TimeKeeper.cpp:37
cepgen::utils::TimeKeeper::clear
void clear()
Reset all counters and the timer.
Definition
TimeKeeper.cpp:27
cepgen::utils::Timer
A generic timer to extract the processing time between two steps in this software's flow.
Definition
Timer.h:30
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
CepGen
Utils
TimeKeeper.h
Generated on Mon Jul 29 2024 for CepGen by
1.9.7