ATLAS Offline Software
JetTrigTimerTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9 #include "gtest/gtest.h"
10 #include <math.h>
11 #include <tuple>
12 
13 
14 double delay(std::size_t d){
15  auto sumNum{0.};
16  for (std::size_t i = 0; i != d; ++i) {
17  sumNum += i* atan(i);
18  }
19  return sumNum;
20 }
21 
22 TEST(JetTrigTimerTest, exerciser) {
23 
24  auto timer = JetTrigTimer(false);
25  EXPECT_EQ(timer.units(), "us");
26 
27  timer = JetTrigTimer(true);
28  EXPECT_EQ(timer.units(), "ns");
29 
30  std::size_t delay_par(10000);
31 
32  auto tup = timer.read_bare();
33  EXPECT_EQ(std::get<0>(tup), 0.); // elapsed time = 0
34  EXPECT_EQ(std::get<1>(tup), 0); // no of calls = 0
35  EXPECT_EQ(std::get<2>(tup), "ns"); // units are ns.
36 
37  timer.start();
38  delay(delay_par);
39  timer.update();
40 
41  tup = timer.read_bare();
42  EXPECT_GE(std::get<0>(tup), 0.0); // elapsed time
43  EXPECT_EQ(std::get<1>(tup), 1); // no of calls
44  EXPECT_EQ(std::get<2>(tup), "ns"); // units are ns.
45 
46  timer.reset();
47  timer.start();
48  double e0 = timer.elapsed_to_now();
49  delay(10);
50  double e1 = timer.elapsed_to_now();
51  delay(10);
52  double e2 = timer.elapsed_to_update();
53 
54 
55  EXPECT_GT(e1, e0);
56  EXPECT_EQ(e2, e1);
57 
58  timer.reset();
59  tup = timer.read_bare();
60  EXPECT_EQ(std::get<0>(tup), 0.0); // elapsed time = 0
61  EXPECT_EQ(std::get<1>(tup), 0); // no of calls = 0
62  EXPECT_EQ(std::get<2>(tup), "ns"); // units are ns.
63 }
egammaEnergyPositionAllSamples::e1
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TEST
TEST(JetTrigTimerTest, exerciser)
Definition: JetTrigTimerTest.cxx:22
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: JetTrigTimerTest.cxx:6
lumiFormat.i
int i
Definition: lumiFormat.py:85
delay
double delay(std::size_t d)
Definition: JetTrigTimerTest.cxx:14
exerciser
Definition: exerciser.py:1
JetTrigTimer
Definition: JetTrigTimer.h:13
JetTrigTimer.h
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
egammaEnergyPositionAllSamples::e0
double e0(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in pre-sampler
checker_macros.h
Define macros for attributes used to control the static checker.