summaryrefslogtreecommitdiffstats
path: root/src/bp_gtest.cpp
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-05-31 13:57:01 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-05-31 13:57:01 +0300
commit5d9c4aa95e28049c2bf4de1e04af73696d122e4b (patch)
treef097f9b1b12a4d42a41b0786dd1b9220bb93c3f2 /src/bp_gtest.cpp
parent06f5cc0b5892712242344fb42cbafd873c5d0209 (diff)
Fixes and better unit test for histogram
Diffstat (limited to 'src/bp_gtest.cpp')
-rwxr-xr-xsrc/bp_gtest.cpp18
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);
}