Show More
@@ -79,7 +79,11 b' class TimeitResult(object):' | |||||
79 | self._precision = precision |
|
79 | self._precision = precision | |
80 |
|
80 | |||
81 | def _repr_pretty_(self, p , cycle): |
|
81 | def _repr_pretty_(self, p , cycle): | |
82 | unic = u"%d loops, best of %d: %s per loop" % (self.loops, self.repeat, |
|
82 | if self.loops == 1: # No s at "loops" if only one loop | |
|
83 | unic = u"%d loop, best of %d: %s per loop" % (self.loops, self.repeat, | |||
|
84 | _format_time(self.best, self._precision)) | |||
|
85 | else: | |||
|
86 | unic = u"%d loops, best of %d: %s per loop" % (self.loops, self.repeat, | |||
83 | _format_time(self.best, self._precision)) |
|
87 | _format_time(self.best, self._precision)) | |
84 | p.text(u'<TimeitResult : '+unic+u'>') |
|
88 | p.text(u'<TimeitResult : '+unic+u'>') | |
85 |
|
89 | |||
@@ -956,7 +960,7 b' python-profiler package from non-free.""")' | |||||
956 | In [5]: import time |
|
960 | In [5]: import time | |
957 |
|
961 | |||
958 | In [6]: %timeit -n1 time.sleep(2) |
|
962 | In [6]: %timeit -n1 time.sleep(2) | |
959 |
1 loop |
|
963 | 1 loop, best of 3: 2 s per loop | |
960 |
|
964 | |||
961 |
|
965 | |||
962 | The times reported by %timeit will be slightly higher than those |
|
966 | The times reported by %timeit will be slightly higher than those | |
@@ -1055,8 +1059,12 b' python-profiler package from non-free.""")' | |||||
1055 | if worst > 4 * best and best > 0 and worst > 1e-6: |
|
1059 | if worst > 4 * best and best > 0 and worst > 1e-6: | |
1056 | print("The slowest run took %0.2f times longer than the " |
|
1060 | print("The slowest run took %0.2f times longer than the " | |
1057 | "fastest. This could mean that an intermediate result " |
|
1061 | "fastest. This could mean that an intermediate result " | |
1058 |
"is being cached |
|
1062 | "is being cached." % (worst / best)) | |
1059 | print(u"%d loops, best of %d: %s per loop" % (number, repeat, |
|
1063 | if number == 1: # No s at "loops" if only one loop | |
|
1064 | print(u"%d loop, best of %d: %s per loop" % (number, repeat, | |||
|
1065 | _format_time(best, precision))) | |||
|
1066 | else: | |||
|
1067 | print(u"%d loops, best of %d: %s per loop" % (number, repeat, | |||
1060 | _format_time(best, precision))) |
|
1068 | _format_time(best, precision))) | |
1061 | if tc > tc_min: |
|
1069 | if tc > tc_min: | |
1062 | print("Compiler time: %.2f s" % tc) |
|
1070 | print("Compiler time: %.2f s" % tc) |
General Comments 0
You need to be logged in to leave comments.
Login now