Skip to content

Commit 2fde590

Browse files
committed
BENCH: Added floor divide benchmarks (numpy#17727)
1 parent 1f104fd commit 2fde590

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

benchmarks/benchmarks/bench_ufunc.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,20 @@ def time_less_than_scalar2(self, dtype):
134134
(self.d < 1)
135135

136136

137-
class CustomScalarInt(Benchmark):
138-
params = [10**size for size in range(1, 8)]
139-
param_names = ['size']
140-
141-
def setup(self, size):
142-
self.x = np.arange(size)
143-
144-
def time_floor_divide(self, size):
145-
self.x//8
137+
class CustomScalarFloorDivideInt(Benchmark):
138+
params = ([np.int8, np.int16, np.int32, np.int64], [8, -8, 43, -43])
139+
param_names = ['dtype', 'divisors']
140+
max_value = 10**7
141+
min_value = -10**7
142+
143+
def setup(self, dtype, divisor):
144+
iinfo = np.iinfo(dtype)
145+
self.x = np.arange(
146+
max(iinfo.min, self.min_value),
147+
min(iinfo.max, self.max_value))
148+
149+
def time_floor_divide_int(self, dtpye, divisor):
150+
self.x // divisor
146151

147152

148153
class Scalar(Benchmark):

0 commit comments

Comments
 (0)