ATLAS Offline Software
Loading...
Searching...
No Matches
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
6#include "gtest/gtest.h"
7#include <math.h>
8#include <tuple>
9
10
11double delay(std::size_t d){
12 auto sumNum{0.};
13 for (std::size_t i = 0; i != d; ++i) {
14 sumNum += i* atan(i);
15 }
16 return sumNum;
17}
18
19TEST(JetTrigTimerTest, exerciser) {
20
21 auto timer = JetTrigTimer(false);
22 EXPECT_EQ(timer.units(), "us");
23
24 timer = JetTrigTimer(true);
25 EXPECT_EQ(timer.units(), "ns");
26
27 std::size_t delay_par(10000);
28
29 auto tup = timer.read_bare();
30 EXPECT_EQ(std::get<0>(tup), 0.); // elapsed time = 0
31 EXPECT_EQ(std::get<1>(tup), 0); // no of calls = 0
32 EXPECT_EQ(std::get<2>(tup), "ns"); // units are ns.
33
34 timer.start();
35 delay(delay_par);
36 timer.update();
37
38 tup = timer.read_bare();
39 EXPECT_GE(std::get<0>(tup), 0.0); // elapsed time
40 EXPECT_EQ(std::get<1>(tup), 1); // no of calls
41 EXPECT_EQ(std::get<2>(tup), "ns"); // units are ns.
42
43 timer.reset();
44 timer.start();
45 double e0 = timer.elapsed_to_now();
46 delay(10);
47 double e1 = timer.elapsed_to_now();
48 delay(10);
49 double e2 = timer.elapsed_to_update();
50
51
52 EXPECT_GT(e1, e0);
53 EXPECT_EQ(e2, e1);
54
55 timer.reset();
56 tup = timer.read_bare();
57 EXPECT_EQ(std::get<0>(tup), 0.0); // elapsed time = 0
58 EXPECT_EQ(std::get<1>(tup), 0); // no of calls = 0
59 EXPECT_EQ(std::get<2>(tup), "ns"); // units are ns.
60}
TEST(JetTrigTimerTest, exerciser)
double delay(std::size_t d)