diff options
| author | Matti Picus <matti.picus@gmail.com> | 2023-02-09 17:01:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-09 16:01:15 +0100 |
| commit | 11a7e2d4aa85e902384bcb9459a83045fab602b4 (patch) | |
| tree | 8abc35474c6512eeeef58b16d60b421649eaddb0 /benchmarks | |
| parent | a91a31e2ff22c3c6cbbc4bacca2d6d7a8fe6bdff (diff) | |
| download | numpy-11a7e2d4aa85e902384bcb9459a83045fab602b4.tar.gz | |
ENH: add indexed loops for maximum, minimum, fmax, fmin (#23177)
Continuation of the ufunc.at optimizations:
add indexed loops for maximum, minimum, fmax, fmin ufuncs and a benchmark for maximum.at (performance increased by ~13x)
* BENCH: add np.maximum.at benchmark
* remove 'explain_chain'
* add a seed to `default_rng() (from review)
* MAINT: formatting and change comments, from review
Diffstat (limited to 'benchmarks')
| -rw-r--r-- | benchmarks/benchmarks/bench_ufunc.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/benchmarks/benchmarks/bench_ufunc.py b/benchmarks/benchmarks/bench_ufunc.py index 090f19224..138f2e9a0 100644 --- a/benchmarks/benchmarks/bench_ufunc.py +++ b/benchmarks/benchmarks/bench_ufunc.py @@ -36,13 +36,17 @@ class Broadcast(Benchmark): class At(Benchmark): def setup(self): - self.vals = np.random.rand(1_000_000) - self.idx = np.random.randint(1000, size=1_000_000).astype(np.intp) + rng = np.random.default_rng(1) + self.vals = rng.random(10_000_000, dtype=np.float64) + self.idx = rng.integers(1000, size=10_000_000).astype(np.intp) self.res = np.zeros(1000, dtype=self.vals.dtype) def time_sum_at(self): np.add.at(self.res, self.idx, self.vals) + def time_maximum_at(self): + np.maximum.at(self.res, self.idx, self.vals) + class UFunc(Benchmark): params = [ufuncs] |
