Mercurial > hg
diff tests/run-tests.py @ 27635:e9f099ede405
tests: only stat a test file if we don't already know its "cost"
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon, 04 Jan 2016 21:54:46 -0800 |
parents | a1eff44c432b |
children | 21b363bd87dc |
line wrap: on
line diff
--- a/tests/run-tests.py Mon Jan 04 21:54:44 2016 -0800 +++ b/tests/run-tests.py Mon Jan 04 21:54:46 2016 -0800 @@ -1845,18 +1845,24 @@ b'gendoc': 100, b'contrib-perf': 200, } + perf = {} def sortkey(f): # run largest tests first, as they tend to take the longest try: - val = -os.stat(f).st_size - except OSError as e: - if e.errno != errno.ENOENT: - raise - return -1e9 # file does not exist, tell early - for kw, mul in slow.items(): - if kw in f: - val *= mul - return val + return perf[f] + except KeyError: + try: + val = -os.stat(f).st_size + except OSError as e: + if e.errno != errno.ENOENT: + raise + perf[f] = -1e9 # file does not exist, tell early + return -1e9 + for kw, mul in slow.items(): + if kw in f: + val *= mul + perf[f] = val + return perf[f] tests.sort(key=sortkey) self._testdir = osenvironb[b'TESTDIR'] = getattr(