diff options
author | Ido Barnea <ibarnea@cisco.com> | 2016-05-31 13:57:01 +0300 |
---|---|---|
committer | Ido Barnea <ibarnea@cisco.com> | 2016-05-31 13:57:01 +0300 |
commit | 5d9c4aa95e28049c2bf4de1e04af73696d122e4b (patch) | |
tree | f097f9b1b12a4d42a41b0786dd1b9220bb93c3f2 /src/bp_gtest.cpp | |
parent | 06f5cc0b5892712242344fb42cbafd873c5d0209 (diff) |
Fixes and better unit test for histogram
Diffstat (limited to 'src/bp_gtest.cpp')
-rwxr-xr-x | src/bp_gtest.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/bp_gtest.cpp b/src/bp_gtest.cpp index 7bb3da0c..86b7821b 100755 --- a/src/bp_gtest.cpp +++ b/src/bp_gtest.cpp @@ -2657,19 +2657,17 @@ public: TEST_F(time_histogram, test_average) { int i; int j; - // Latency is calculated by low pass filter, so need to give it time to stabilize - for (j=0; j < 13; j++) { - for (i=0; i<100; i++) { - m_hist.Add(10e-6); - } - for (i=0; i<100; i++) { - m_hist.Add(10e-3); + for (j = 0; j < 10; j++) { + for (i = 0; i <= 2000; i++) { + m_hist.Add(10e-7 * i); } m_hist.update(); + // Latency is calculated using low pass filter, with initial value of 0 + EXPECT_EQ(m_hist.get_average_latency(), 1000.0 - (1000.0 / (2 << j))); + EXPECT_EQ(m_hist.get_count(), 2001 * (j+1)); + EXPECT_EQ(m_hist.get_high_count(), 2001 * (j+1) - (11 * (j+1))); + EXPECT_EQ(m_hist.get_max_latency(), 2000); } - - EXPECT_GT(m_hist.get_average_latency(), 5004); - EXPECT_LT(m_hist.get_average_latency(), 5005); m_hist.Dump(stdout); } |