diff options
author | MichaelSaah <mike.saah@gmail.com> | 2018-09-05 18:32:32 +0000 |
---|---|---|
committer | MichaelSaah <mike.saah@gmail.com> | 2018-09-05 18:32:32 +0000 |
commit | a8f65901a635261f97d26804b366e83dc160112d (patch) | |
tree | 879a35c2f6a5c8d29eec7cd5bd302d0da88d4939 /benchmarks | |
parent | 340405dbdd79786fdfa469ec356e78d2cd0a7d67 (diff) | |
download | numpy-a8f65901a635261f97d26804b366e83dc160112d.tar.gz |
BENCH: Split bench_function_base.Sort into Sort and SortWorst.
SortWorst houses the worst-case setup code and the time_sort_worst method.
Everything else remains in Sort.
Done in response to issue #11875
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/benchmarks/bench_function_base.py | 28 |
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) |