timeit: add newlines to output for readability

Issue #28240.
This commit is contained in:
Victor Stinner 2016-10-18 17:55:18 +02:00
parent c3e40f8c5b
commit 62cca920db
2 changed files with 8 additions and 1 deletions

View File

@ -297,7 +297,9 @@ class TestTimeit(unittest.TestCase):
s = self.run_main(switches=['-v'])
self.assertEqual(s, dedent("""\
1 loop -> 1 secs
raw times: 1 sec, 1 sec, 1 sec, 1 sec, 1 sec
1 loop, best of 5: 1 sec per loop
"""))
@ -309,7 +311,9 @@ class TestTimeit(unittest.TestCase):
100 loops -> 0.005 secs
1000 loops -> 0.05 secs
10000 loops -> 0.5 secs
raw times: 500 msec, 500 msec, 500 msec, 500 msec, 500 msec
10000 loops, best of 5: 50 usec per loop
"""))

View File

@ -325,6 +325,9 @@ def main(args=None, *, _wrap_timer=None):
t.print_exc()
return 1
if verbose:
print()
try:
raw_timings = t.repeat(repeat, number)
except:
@ -347,7 +350,7 @@ def main(args=None, *, _wrap_timer=None):
if verbose:
print("raw times: %s" % ", ".join(map(format_time, raw_timings)))
print()
timings = [dt / number for dt in raw_timings]
best = min(timings)