cpython: 2dafb2f3e7ff (original) (raw)

--- a/Lib/test/test_timeit.py +++ b/Lib/test/test_timeit.py @@ -12,7 +12,7 @@ from test.support import captured_stderr DEFAULT_NUMBER = 1000000

timeit's default number of repetitions.

-DEFAULT_REPEAT = 3 +DEFAULT_REPEAT = 5

XXX: some tests are commented out that would improve the coverage but take a

long time to run because they test the default number of loops, which is

@@ -226,7 +226,7 @@ class TestTimeit(unittest.TestCase): t.print_exc(s) self.assert_exc_string(s.getvalue(), 'ZeroDivisionError')

def run_main(self, seconds_per_increment=1.0, switches=None, timer=None): if timer is None: @@ -252,31 +252,31 @@ class TestTimeit(unittest.TestCase): def test_main_seconds(self): s = self.run_main(seconds_per_increment=5.5)

def test_main_milliseconds(self): s = self.run_main(seconds_per_increment=0.0055)

def test_main_microseconds(self): s = self.run_main(seconds_per_increment=0.0000025, switches=['-n100'])

def test_main_fixed_iters(self): s = self.run_main(seconds_per_increment=2.0, switches=['-n35'])

def test_main_setup(self): s = self.run_main(seconds_per_increment=2.0, switches=['-n35', '-s', 'print("CustomSetup")'])

def test_main_multiple_setups(self): s = self.run_main(seconds_per_increment=2.0, switches=['-n35', '-s', 'a = "CustomSetup"', '-s', 'print(a)'])

def test_main_fixed_reps(self): s = self.run_main(seconds_per_increment=60.0, switches=['-r9']) @@ -309,8 +309,8 @@ class TestTimeit(unittest.TestCase): s = self.run_main(switches=['-v']) self.assertEqual(s, dedent("""[](#l1.63) 1 loop -> 1 secs

def test_main_very_verbose(self): @@ -321,23 +321,23 @@ class TestTimeit(unittest.TestCase): 100 loops -> 0.005 secs 1000 loops -> 0.05 secs 10000 loops -> 0.5 secs

def test_main_with_time_unit(self): unit_sec = self.run_main(seconds_per_increment=0.002, switches=['-u', 'sec']) self.assertEqual(unit_sec,

--- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -59,7 +59,7 @@ import itertools dummy_src_name = "" default_number = 1000000 -default_repeat = 3 +default_repeat = 5 default_timer = time.perf_counter _globals = globals

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -88,6 +88,9 @@ Core and Builtins Library ------- +- Issue #28240: timeit now repeats the benchmarks 5 times instead of only 3