Fix some flakiness in test.
authorShashi Shekhar <shashishekhar@google.com>
Thu, 26 Apr 2018 23:11:11 +0000 (16:11 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Thu, 26 Apr 2018 23:14:09 +0000 (16:14 -0700)
PiperOrigin-RevId: 194470125

tensorflow/contrib/lite/profiling/profiler_test.cc

index 7914f36..7ea1d8f 100644 (file)
@@ -82,16 +82,15 @@ TEST(ProfilingTest, ProfilesAreCollected) {
   EXPECT_EQ("Child", profile_events[3]->tag);
   EXPECT_EQ("SleepForQuarter", profile_events[4]->tag);
 
-  AssertDurationOfEventAroundMs(profile_events[0], /*expected_ms*/ 500,
-                                /*eps_ms*/ 2);
-  AssertDurationOfEventAroundMs(profile_events[1], /*expected_ms*/ 250,
-                                /*eps_ms*/ 2);
-  AssertDurationOfEventAroundMs(profile_events[2], /*expected_ms*/ 250,
-                                /*eps_ms*/ 2);
-  AssertDurationOfEventAroundMs(profile_events[3], /*expected_ms*/ 250,
-                                /*eps_ms*/ 2);
-  AssertDurationOfEventAroundMs(profile_events[4], /*expected_ms*/ 250,
-                                /*eps_ms*/ 2);
+#ifndef ADDRESS_SANITIZER
+  // ASAN build is sometimes very slow.
+  const int eps_ms = 10;
+  AssertDurationOfEventAroundMs(profile_events[0], /*expected_ms*/ 500, eps_ms);
+  AssertDurationOfEventAroundMs(profile_events[1], /*expected_ms*/ 250, eps_ms);
+  AssertDurationOfEventAroundMs(profile_events[2], /*expected_ms*/ 250, eps_ms);
+  AssertDurationOfEventAroundMs(profile_events[3], /*expected_ms*/ 250, eps_ms);
+  AssertDurationOfEventAroundMs(profile_events[4], /*expected_ms*/ 250, eps_ms);
+#endif
 }
 
 }  // namespace