Skip to content

Commit

Permalink
Add timer to run_tests.py
Browse files Browse the repository at this point in the history
For future profiling work to eliminate/speed-up slow tests.
  • Loading branch information
ctiller committed Feb 26, 2015
1 parent 238cdbf commit 9d6139a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/run_tests/jobset.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(self, spec, bin_hash, newline_on_success, travis):
env = os.environ.copy()
for k, v in spec.environ.iteritems():
env[k] = v
self._start = time.time()
self._process = subprocess.Popen(args=spec.cmdline,
stderr=subprocess.STDOUT,
stdout=self._tempfile,
Expand All @@ -174,6 +175,7 @@ def __init__(self, spec, bin_hash, newline_on_success, travis):
def state(self, update_cache):
"""Poll current state of the job. Prints messages at completion."""
if self._state == _RUNNING and self._process.poll() is not None:
elapsed = time.time() - self._start
if self._process.returncode != 0:
self._state = _FAILURE
self._tempfile.seek(0)
Expand All @@ -182,7 +184,7 @@ def state(self, update_cache):
self._spec.shortname, self._process.returncode), stdout)
else:
self._state = _SUCCESS
message('PASSED', self._spec.shortname,
message('PASSED', '%s [time=%.1fsec]' % (self._spec.shortname, elapsed),
do_newline=self._newline_on_success or self._travis)
if self._bin_hash:
update_cache.finished(self._spec.identity(), self._bin_hash)
Expand Down

0 comments on commit 9d6139a

Please sign in to comment.