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 }
Device for conveniently storing and analysing benchmarking times.
Definition: time_data.hpp:39
TEST(TimeDataTests, container)
void push_back(const ecl::Duration &duration)
Append a new timing measurement to the sequence.
Definition: time_data.hpp:49
ecl::Duration average() const
Return the average of the elements currently stored.
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.
Definition: duration.hpp:41
ecl::Duration stdDev() const
Return the standard deviation of the elements currently stored.
void clear()
Reset the container (i.e. clear it).
Definition: time_data.hpp:53
int main(int argc, char **argv)
ecl::Duration variance() const
Return the variance of the elements currently stored.


ecl_time
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:15