Project
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
17
18#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_COMMON_H_
19#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_COMMON_H_
20
21#include <TStopwatch.h>
22#include "Framework/Logger.h"
23
24namespace o2
25{
26namespace hmpid
27{
28
29// ------- Execution time functions -------
30
34{
35 private:
36 TStopwatch mTimer;
37 Double_t mStartTime;
38 Double_t mLastLogTime;
39 Double_t mElapseLogTime;
40
41 public:
43 {
44 mStartTime = 0;
45 mLastLogTime = 0;
46 mElapseLogTime = 10; // default 10 seconds
47 };
48
49 ~ExecutionTimer() = default;
50
53 Double_t getElapseLogTime() { return mElapseLogTime; };
54
57 void setElapseLogTime(Double_t interval)
58 {
59 mElapseLogTime = interval;
60 return;
61 };
62
64 void start()
65 {
66 mStartTime = mTimer.CpuTime();
67 mLastLogTime = mStartTime;
68 mTimer.Start(false);
69 return;
70 };
71
73 void stop()
74 {
75 mTimer.Stop();
76 return;
77 };
78
81 void logMes(std::string const message)
82 {
83 LOG(info) << message << " Execution time = " << (mTimer.CpuTime() - mStartTime);
84 mTimer.Continue();
85 return;
86 };
87
91 void elapseMes(std::string const message)
92 {
93 if (mTimer.CpuTime() - mLastLogTime > mElapseLogTime) {
94 LOG(info) << message << " Execution time = " << (mTimer.CpuTime() - mStartTime);
95 mLastLogTime = mTimer.CpuTime();
96 }
97 mTimer.Continue();
98 return;
99 };
100};
101
102} // namespace hmpid
103} // namespace o2
104
105#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDBASE_COMMON_H_ */
HMPID Derived class for the Time of Workflows.
Definition Common.h:34
void stop()
stop : stops the timer
Definition Common.h:73
void elapseMes(std::string const message)
Definition Common.h:91
Double_t getElapseLogTime()
Definition Common.h:53
void start()
start : starts the timer
Definition Common.h:64
void setElapseLogTime(Double_t interval)
Definition Common.h:57
void logMes(std::string const message)
Definition Common.h:81
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"