Show More
@@ -85,9 +85,17 b' class TimeitResult(object):' | |||
|
85 | 85 | return (math.fsum([(x - mean) ** 2 for x in self.timings]) / len(self.timings)) ** 0.5 |
|
86 | 86 | |
|
87 | 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 | 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 | 97 | .format( |
|
98 | pm = pm, | |
|
91 | 99 | runs = self.repeat, |
|
92 | 100 | loops = self.loops, |
|
93 | 101 | loop_plural = "" if self.loops == 1 else "s", |
@@ -598,12 +598,12 b' class TestAstTransform(unittest.TestCase):' | |||
|
598 | 598 | called.add(x) |
|
599 | 599 | ip.push({'f':f}) |
|
600 | 600 | |
|
601 |
with tt.AssertPrints(" |
|
|
601 | with tt.AssertPrints("std. dev. of"): | |
|
602 | 602 | ip.run_line_magic("timeit", "-n1 f(1)") |
|
603 | 603 | self.assertEqual(called, {-1}) |
|
604 | 604 | called.clear() |
|
605 | 605 | |
|
606 |
with tt.AssertPrints(" |
|
|
606 | with tt.AssertPrints("std. dev. of"): | |
|
607 | 607 | ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") |
|
608 | 608 | self.assertEqual(called, {-2, -3}) |
|
609 | 609 | |
@@ -671,12 +671,12 b' class TestAstTransform2(unittest.TestCase):' | |||
|
671 | 671 | called.add(x) |
|
672 | 672 | ip.push({'f':f}) |
|
673 | 673 | |
|
674 |
with tt.AssertPrints(" |
|
|
674 | with tt.AssertPrints("std. dev. of"): | |
|
675 | 675 | ip.run_line_magic("timeit", "-n1 f(1)") |
|
676 | 676 | self.assertEqual(called, {(1,)}) |
|
677 | 677 | called.clear() |
|
678 | 678 | |
|
679 |
with tt.AssertPrints(" |
|
|
679 | with tt.AssertPrints("std. dev. of"): | |
|
680 | 680 | ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") |
|
681 | 681 | self.assertEqual(called, {(2,), (3,)}) |
|
682 | 682 |
General Comments 0
You need to be logged in to leave comments.
Login now