Show More
@@ -85,9 +85,17 b' class TimeitResult(object):' | |||||
85 | return (math.fsum([(x - mean) ** 2 for x in self.timings]) / len(self.timings)) ** 0.5 |
|
85 | return (math.fsum([(x - mean) ** 2 for x in self.timings]) / len(self.timings)) ** 0.5 | |
86 |
|
86 | |||
87 | def __str__(self): |
|
87 | def __str__(self): | |
|
88 | pm = '+-' | |||
|
89 | if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding: | |||
|
90 | try: | |||
|
91 | u'\xb1'.encode(sys.stdout.encoding) | |||
|
92 | pm = u'\xb1' | |||
|
93 | except: | |||
|
94 | pass | |||
88 | return ( |
|
95 | return ( | |
89 |
u"{mean} |
|
96 | u"{mean} {pm} {std} per loop (mean {pm} std. dev. of {runs} run{run_plural}, {loops} loop{loop_plural} each)" | |
90 | .format( |
|
97 | .format( | |
|
98 | pm = pm, | |||
91 | runs = self.repeat, |
|
99 | runs = self.repeat, | |
92 | loops = self.loops, |
|
100 | loops = self.loops, | |
93 | loop_plural = "" if self.loops == 1 else "s", |
|
101 | loop_plural = "" if self.loops == 1 else "s", |
@@ -598,12 +598,12 b' class TestAstTransform(unittest.TestCase):' | |||||
598 | called.add(x) |
|
598 | called.add(x) | |
599 | ip.push({'f':f}) |
|
599 | ip.push({'f':f}) | |
600 |
|
600 | |||
601 |
with tt.AssertPrints(" |
|
601 | with tt.AssertPrints("std. dev. of"): | |
602 | ip.run_line_magic("timeit", "-n1 f(1)") |
|
602 | ip.run_line_magic("timeit", "-n1 f(1)") | |
603 | self.assertEqual(called, {-1}) |
|
603 | self.assertEqual(called, {-1}) | |
604 | called.clear() |
|
604 | called.clear() | |
605 |
|
605 | |||
606 |
with tt.AssertPrints(" |
|
606 | with tt.AssertPrints("std. dev. of"): | |
607 | ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") |
|
607 | ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") | |
608 | self.assertEqual(called, {-2, -3}) |
|
608 | self.assertEqual(called, {-2, -3}) | |
609 |
|
609 | |||
@@ -671,12 +671,12 b' class TestAstTransform2(unittest.TestCase):' | |||||
671 | called.add(x) |
|
671 | called.add(x) | |
672 | ip.push({'f':f}) |
|
672 | ip.push({'f':f}) | |
673 |
|
673 | |||
674 |
with tt.AssertPrints(" |
|
674 | with tt.AssertPrints("std. dev. of"): | |
675 | ip.run_line_magic("timeit", "-n1 f(1)") |
|
675 | ip.run_line_magic("timeit", "-n1 f(1)") | |
676 | self.assertEqual(called, {(1,)}) |
|
676 | self.assertEqual(called, {(1,)}) | |
677 | called.clear() |
|
677 | called.clear() | |
678 |
|
678 | |||
679 |
with tt.AssertPrints(" |
|
679 | with tt.AssertPrints("std. dev. of"): | |
680 | ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") |
|
680 | ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") | |
681 | self.assertEqual(called, {(2,), (3,)}) |
|
681 | self.assertEqual(called, {(2,), (3,)}) | |
682 |
|
682 |
General Comments 0
You need to be logged in to leave comments.
Login now