|
55 | 55 | ('stupid benchmark', 'zero', 1, 0.0, 0)]
|
56 | 56 | """
|
57 | 57 |
|
58 | | -from time import time as clock |
59 | | -from copy import copy |
60 | | -from functools import reduce |
61 | | - |
62 | 58 | # This part handles the ctrl-c interruption.
|
63 | 59 | # class CTRLC(Exception):
|
64 | 60 | # def __init__(self):
|
65 | 61 | # pass
|
66 | | - |
67 | 62 | import signal
|
| 63 | +from copy import copy |
| 64 | +from functools import reduce |
| 65 | +from time import time as clock |
68 | 66 |
|
69 | 67 |
|
70 | 68 | def signal_ctrl_c(signal, frame):
|
@@ -176,9 +174,9 @@ def __init__(self, benchmarks):
|
176 | 174 | """
|
177 | 175 | if isinstance(benchmarks, Benchmark):
|
178 | 176 | self._benchmarks = (benchmarks, )
|
179 | | - elif isinstance(benchmarks, (list, tuple)) and all([isinstance(i, Benchmark) for i in benchmarks]): |
| 177 | + elif isinstance(benchmarks, (list, tuple)) and all(isinstance(i, Benchmark) for i in benchmarks): |
180 | 178 | self._benchmarks = tuple(benchmarks)
|
181 | | - elif isinstance(benchmarks, (list, tuple)) and all([isinstance(i, (list, tuple)) for i in benchmarks]): |
| 179 | + elif isinstance(benchmarks, (list, tuple)) and all(isinstance(i, (list, tuple)) for i in benchmarks): |
182 | 180 | self._benchmarks = tuple(Benchmark(i) for i in benchmarks)
|
183 | 181 | else:
|
184 | 182 | self._benchmarks = (Benchmark(benchmarks),)
|
@@ -350,7 +348,7 @@ def averages(self):
|
350 | 348 | timings = self.timings(transposed=True)
|
351 | 349 | res = {}
|
352 | 350 | for bm in timings:
|
353 | | - totals = map(lambdaa: sum(a) / len(a), timings[bm]) |
| 351 | + totals = (sum(a) / len(a)forain timings[bm]) |
354 | 352 | res[bm] = totals
|
355 | 353 | return res
|
356 | 354 |
|
@@ -409,8 +407,8 @@ def __add__(self, other):
|
409 | 407 | """
|
410 | 408 | raise NotImplementedError("Not verified since Runner system")
|
411 | 409 | import re
|
412 | | - my_labels = set(b.label() for b in self._benchmarks) |
413 | | - ot_labels = set(b.label() for b in other._benchmarks) |
| 410 | + my_labels = {b.label() for b in self._benchmarks} |
| 411 | + ot_labels = {b.label() for b in other._benchmarks} |
414 | 412 | collisions = my_labels.intersect(ot_labels)
|
415 | 413 | if collisions:
|
416 | 414 | autolabel = re.compile(_autolabel_regex)
|
@@ -677,8 +675,8 @@ class ParallelRunner:
|
677 | 675 | As input, it takes a list or tuple of the inputs that will be given to the benchmarks.
|
678 | 676 | """
|
679 | 677 | def __init__(self, bleachermark, runs):
|
680 | | - from sage.parallel.decorate import parallel |
681 | 678 | from sage.functions.other import ceil, floor
|
| 679 | + from sage.parallel.decorate import parallel |
682 | 680 | self._benchmarks = bleachermark._benchmarks
|
683 | 681 | # profiling we run each benchmark once
|
684 | 682 | self._totaltime = reduce(lambda a, b: a + b, [r[0] for bm in self._benchmarks for r in bm.run(runs[0])[1:]])
|
|
0 commit comments