From d7da550fc7b1f9ab3394c927c5078c22f75b8eca Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 8 Jun 2020 14:36:42 -0700 Subject: [PATCH] Make eager/monitoring_test.py less flaky. MonitoredTimer measures wall time, so we're susceptible to the process being interrupted. To measure time intervals of different lengths, wrap them inside each other, that way guaranteeing that the inner one is shorter than the outer one. PiperOrigin-RevId: 315355335 Change-Id: I6eb136f221f4b96917ad8f6708f4a9bad18841c9 --- tensorflow/python/eager/monitoring_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/eager/monitoring_test.py b/tensorflow/python/eager/monitoring_test.py index 7cb8c0c2cd1..de9d3bcb8f4 100644 --- a/tensorflow/python/eager/monitoring_test.py +++ b/tensorflow/python/eager/monitoring_test.py @@ -104,10 +104,10 @@ class MonitoringTest(test_util.TensorFlowTestCase): def test_context_manager(self): counter = monitoring.Counter('test/ctxmgr', 'test context manager', 'slot') - with monitoring.MonitoredTimer(counter.get_cell('short')): - time.sleep(0.001) with monitoring.MonitoredTimer(counter.get_cell('long')): - time.sleep(0.02) + time.sleep(0.01) + with monitoring.MonitoredTimer(counter.get_cell('short')): + time.sleep(0.01) self.assertGreater( counter.get_cell('long').value(), counter.get_cell('short').value())