Skip to content

Commit 9ff22ec

Browse files
author
Yangqing Jia
committed
relax benchmark milliseconds threshold
1 parent f29d4bd commit 9ff22ec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/caffe/test/test_benchmark.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace caffe {
1111

12+
const float kMillisecondsThreshold = 30;
13+
1214
template <typename TypeParam>
1315
class BenchmarkTest : public MultiDeviceTest<TypeParam> {};
1416

@@ -63,8 +65,8 @@ TYPED_TEST(BenchmarkTest, TestTimerMilliSeconds) {
6365
EXPECT_FALSE(timer.has_run_at_least_once());
6466
timer.Start();
6567
usleep(300 * 1000);
66-
EXPECT_GE(timer.MilliSeconds(), 290);
67-
EXPECT_LE(timer.MilliSeconds(), 310);
68+
EXPECT_GE(timer.MilliSeconds(), 300 - kMillisecondsThreshold);
69+
EXPECT_LE(timer.MilliSeconds(), 300 + kMillisecondsThreshold);
6870
EXPECT_TRUE(timer.initted());
6971
EXPECT_FALSE(timer.running());
7072
EXPECT_TRUE(timer.has_run_at_least_once());
@@ -78,8 +80,8 @@ TYPED_TEST(BenchmarkTest, TestTimerSeconds) {
7880
EXPECT_FALSE(timer.has_run_at_least_once());
7981
timer.Start();
8082
usleep(300 * 1000);
81-
EXPECT_GE(timer.Seconds(), 0.290);
82-
EXPECT_LE(timer.Seconds(), 0.310);
83+
EXPECT_GE(timer.Seconds(), 0.3 - kMillisecondsThreshold / 1000.);
84+
EXPECT_LE(timer.Seconds(), 0.3 + kMillisecondsThreshold / 1000.);
8385
EXPECT_TRUE(timer.initted());
8486
EXPECT_FALSE(timer.running());
8587
EXPECT_TRUE(timer.has_run_at_least_once());

0 commit comments

Comments
 (0)