Show More
@@ -71,10 +71,11 b' class TimeitResult(object):' | |||||
71 | compile_time: (float) time of statement compilation (s) |
|
71 | compile_time: (float) time of statement compilation (s) | |
72 |
|
72 | |||
73 | """ |
|
73 | """ | |
74 |
|
74 | def __init__(self, loops, repeat, best, worst, all_runs, compile_time, precision): | ||
75 | def __init__(self, loops, repeat, all_runs, compile_time, precision): |
|
|||
76 | self.loops = loops |
|
75 | self.loops = loops | |
77 | self.repeat = repeat |
|
76 | self.repeat = repeat | |
|
77 | self.best = best | |||
|
78 | self.worst = worst | |||
78 | self.all_runs = all_runs |
|
79 | self.all_runs = all_runs | |
79 | self.compile_time = compile_time |
|
80 | self.compile_time = compile_time | |
80 | self._precision = precision |
|
81 | self._precision = precision | |
@@ -1063,7 +1064,9 b' python-profiler package from non-free.""")' | |||||
1063 | break |
|
1064 | break | |
1064 |
|
1065 | |||
1065 | all_runs = timer.repeat(repeat, number) |
|
1066 | all_runs = timer.repeat(repeat, number) | |
1066 | timeit_result = TimeitResult(number, repeat, all_runs, tc, precision) |
|
1067 | best = min(all_runs) / number | |
|
1068 | worst = max(all_runs) / number | |||
|
1069 | timeit_result = TimeitResult(number, repeat, best, worst, all_runs, tc, precision) | |||
1067 |
|
1070 | |||
1068 | if not quiet : |
|
1071 | if not quiet : | |
1069 | # Check best timing is greater than zero to avoid a |
|
1072 | # Check best timing is greater than zero to avoid a | |
@@ -1071,9 +1074,14 b' python-profiler package from non-free.""")' | |||||
1071 | # In cases where the slowest timing is lesser than a micosecond |
|
1074 | # In cases where the slowest timing is lesser than a micosecond | |
1072 | # we assume that it does not really matter if the fastest |
|
1075 | # we assume that it does not really matter if the fastest | |
1073 | # timing is 4 times faster than the slowest timing or not. |
|
1076 | # timing is 4 times faster than the slowest timing or not. | |
1074 | print( timeit_result ) |
|
1077 | if worst > 4 * best and best > 0 and worst > 1e-6: | |
1075 |
|
1078 | print("The slowest run took %0.2f times longer than the " | ||
1076 | if tc > tc_min: |
|
1079 | "fastest. This could mean that an intermediate result " | |
|
1080 | "is being cached." % (worst / best)) | |||
|
1081 | ||||
|
1082 | print( timeit_result ) | |||
|
1083 | ||||
|
1084 | if tc > tc_min: | |||
1077 | print("Compiler time: %.2f s" % tc) |
|
1085 | print("Compiler time: %.2f s" % tc) | |
1078 | if return_result: |
|
1086 | if return_result: | |
1079 | return timeit_result |
|
1087 | return timeit_result |
General Comments 0
You need to be logged in to leave comments.
Login now