Log individual test times to help users track down long-running tests.
PiperOrigin-RevId: 308717463 Change-Id: I4e44952dfb782e7dc2ec57ba730d49b67e5628eb
This commit is contained in:
parent
2658a4a20c
commit
bd954723e3
@ -31,6 +31,7 @@ import random
|
||||
import re
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from absl.testing import parameterized
|
||||
@ -1902,6 +1903,7 @@ class TensorFlowTestCase(googletest.TestCase):
|
||||
self._threads = []
|
||||
self._tempdir = None
|
||||
self._cached_session = None
|
||||
self._test_start_time = None
|
||||
|
||||
def setUp(self):
|
||||
self._ClearCachedSession()
|
||||
@ -1925,7 +1927,15 @@ class TensorFlowTestCase(googletest.TestCase):
|
||||
if self.id().endswith(".test_session"):
|
||||
self.skipTest("Not a test.")
|
||||
|
||||
self._test_start_time = time.time()
|
||||
|
||||
def tearDown(self):
|
||||
# If a subclass overrides setUp and doesn't call the parent class's setUp,
|
||||
# then we may not have set the start time.
|
||||
if self._test_start_time is not None:
|
||||
logging.info("time(%s): %ss", self.id(),
|
||||
round(time.time() - self._test_start_time, 2))
|
||||
|
||||
for thread in self._threads:
|
||||
thread.check_termination()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user