summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2019-07-10 22:01:40 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2019-07-11 10:30:54 -0400
commit47fd29d5e3f6046bb3710417a98d77638005e36d (patch)
tree64b2542d159686828f18413576c53a7fc272ad7c /benchmarks
parent4c5f758c3bdb5cca1dbb9b8099102656bd6ee86c (diff)
downloadnumpy-47fd29d5e3f6046bb3710417a98d77638005e36d.tar.gz
add benchmark
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmarks/bench_random.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/benchmarks/benchmarks/bench_random.py b/benchmarks/benchmarks/bench_random.py
index d9302a494..c52b463e5 100644
--- a/benchmarks/benchmarks/bench_random.py
+++ b/benchmarks/benchmarks/bench_random.py
@@ -173,3 +173,16 @@ class Bounded(Benchmark):
self.rg.randint(0, max + 1, nom_size, dtype=dt)
else:
self.rg.integers(0, max + 1, nom_size, dtype=dt)
+
+class Choice(Benchmark):
+ params = [1e3, 1e6, 1e8]
+
+ def setup(self, v):
+ self.a = np.arange(v)
+ self.rng = np.random.default_rng()
+
+ def time_legacy_choice(self, v):
+ np.random.choice(self.a, 1000, replace=False)
+
+ def time_choice(self, v):
+ self.rng.choice(self.a, 1000, replace=False)