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