summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmarks/benchmarks/bench_function_base.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/benchmarks/benchmarks/bench_function_base.py b/benchmarks/benchmarks/bench_function_base.py
index a45525793..9ef03262b 100644
--- a/benchmarks/benchmarks/bench_function_base.py
+++ b/benchmarks/benchmarks/bench_function_base.py
@@ -105,14 +105,6 @@ class Sort(Benchmark):
self.equal = np.ones(10000)
self.many_equal = np.sort(np.arange(10000) % 10)
- # quicksort median of 3 worst case
- self.worst = np.arange(1000000)
- x = self.worst
- while x.size > 3:
- mid = x.size // 2
- x[mid], x[-2] = x[-2], x[mid]
- x = x[:-2]
-
def time_sort(self):
np.sort(self.e)
@@ -128,9 +120,6 @@ class Sort(Benchmark):
def time_sort_many_equal(self):
self.many_equal.sort()
- def time_sort_worst(self):
- np.sort(self.worst)
-
def time_argsort(self):
self.e.argsort()
@@ -138,6 +127,23 @@ class Sort(Benchmark):
self.o.argsort()
+class SortWorst(Benchmark):
+ def setup(self):
+ # quicksort median of 3 worst case
+ self.worst = np.arange(1000000)
+ x = self.worst
+ while x.size > 3:
+ mid = x.size // 2
+ x[mid], x[-2] = x[-2], x[mid]
+ x = x[:-2]
+
+ def time_sort_worst(self):
+ np.sort(self.worst)
+
+ # Retain old benchmark name for backward compatability
+ time_sort_worst.benchmark_name = "bench_function_base.Sort.time_sort_worst"
+
+
class Where(Benchmark):
def setup(self):
self.d = np.arange(20000)