Show More
@@ -1006,17 +1006,25 b' python-profiler package from non-free.""")' | |||
|
1006 | 1006 | exec(code, self.shell.user_ns, ns) |
|
1007 | 1007 | timer.inner = ns["inner"] |
|
1008 | 1008 | |
|
1009 | # This is used to check if there is a huge difference between the | |
|
1010 | # best and worst timings. | |
|
1011 | # Issue: https://github.com/ipython/ipython/issues/6471 | |
|
1012 | worst_tuning = 0 | |
|
1009 | 1013 | if number == 0: |
|
1010 | 1014 | # determine number so that 0.2 <= total time < 2.0 |
|
1011 | 1015 | number = 1 |
|
1012 | 1016 | for _ in range(1, 10): |
|
1013 |
|
|
|
1017 | time_number = timer.timeit(number) | |
|
1018 | worst_tuning = max(worst_tuning, time_number / number) | |
|
1019 | if time_number >= 0.2: | |
|
1014 | 1020 | break |
|
1015 | 1021 | number *= 10 |
|
1016 | 1022 | all_runs = timer.repeat(repeat, number) |
|
1017 | 1023 | best = min(all_runs) / number |
|
1018 | 1024 | if not quiet : |
|
1019 | 1025 | worst = max(all_runs) / number |
|
1026 | if worst_tuning: | |
|
1027 | worst = max(worst, worst_tuning) | |
|
1020 | 1028 | if worst > 4 * best: |
|
1021 | 1029 | warn("Worst time is %0.2f times that of the best. Timings may " |
|
1022 | 1030 | "be biased." % (worst / best)) |
General Comments 0
You need to be logged in to leave comments.
Login now