test/time_data.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Includes
10 *****************************************************************************/
11 
12 #include <cstdlib>
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/time/time_data.hpp"
15 
16 /*****************************************************************************
17 ** Using
18 *****************************************************************************/
19 
20 using ecl::Duration;
21 using ecl::TimeData;
22 
23 /*****************************************************************************
24 ** Tests
25 *****************************************************************************/
26 
27 TEST(TimeDataTests,container) {
28  TimeData time_data;
29  Duration duration;
30  duration.stamp(1,0);
31  time_data.push_back(duration);
32  time_data.push_back(duration);
33  time_data.clear();
34  SUCCEED();
35 }
36 
37 TEST(TimeDataTests,statistics) {
38  TimeData time_data;
39  Duration duration;
40  duration.stamp(1,0);
41  time_data.push_back(duration);
42  duration.stamp(2,0);
43  time_data.push_back(duration);
44  double avg = time_data.average();
45  EXPECT_LT(1.49,avg); // Allow for some roundoff error.
46  EXPECT_GT(1.51,avg);
47  double std_dev = time_data.stdDev();
48  EXPECT_LT(0.49,std_dev); // Allow for some roundoff error.
49  EXPECT_GT(0.51,std_dev);
50  double variance = time_data.variance();
51  EXPECT_LT(0.24,variance); // Allow for some roundoff error.
52  EXPECT_GT(0.26,variance);
53 }
54 /*****************************************************************************
55 ** Main program
56 *****************************************************************************/
57 
58 int main(int argc, char **argv) {
59 
60  testing::InitGoogleTest(&argc,argv);
61  return RUN_ALL_TESTS();
62 }
ecl::TimeData
Device for conveniently storing and analysing benchmarking times.
Definition: time_data.hpp:45
main
int main(int argc, char **argv)
Definition: test/time_data.cpp:58
ecl::TimeData::clear
void clear()
Reset the container (i.e. clear it).
Definition: time_data.hpp:67
ecl::TimeData::average
ecl::Duration average() const
Return the average of the elements currently stored.
Definition: lib/time_data.cpp:30
ecl::Duration
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.
Definition: duration.hpp:47
ecl::TimeData::stdDev
ecl::Duration stdDev() const
Return the standard deviation of the elements currently stored.
Definition: lib/time_data.cpp:38
TEST
TEST(TimeDataTests, container)
Definition: test/time_data.cpp:27
ecl::TimeData::push_back
void push_back(const ecl::Duration &duration)
Append a new timing measurement to the sequence.
Definition: time_data.hpp:63
ecl::TimeData::variance
ecl::Duration variance() const
Return the variance of the elements currently stored.
Definition: lib/time_data.cpp:48


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:19