Skip to content

Commit 0176228

Browse files
ASV: add frame ops benchmarks for varying n_rows/n_columns ratios (#39848)
1 parent 9313631 commit 0176228

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

asv_bench/benchmarks/arithmetic.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,26 @@ class FrameWithFrameWide:
116116
operator.add,
117117
operator.floordiv,
118118
operator.gt,
119-
]
119+
],
120+
[
121+
# (n_rows, n_columns)
122+
(1_000_000, 10),
123+
(100_000, 100),
124+
(10_000, 1000),
125+
(1000, 10_000),
126+
],
120127
]
121-
param_names = ["op"]
128+
param_names = ["op", "shape"]
122129

123-
def setup(self, op):
130+
def setup(self, op, shape):
124131
# we choose dtypes so as to make the blocks
125132
# a) not perfectly match between right and left
126133
# b) appreciably bigger than single columns
127-
n_cols = 2000
128-
n_rows = 500
134+
n_rows, n_cols = shape
135+
136+
if op is operator.floordiv:
137+
# floordiv is much slower than the other operations -> use less data
138+
n_rows = n_rows // 10
129139

130140
# construct dataframe with 2 blocks
131141
arr1 = np.random.randn(n_rows, n_cols // 2).astype("f8")
@@ -137,7 +147,7 @@ def setup(self, op):
137147
df._consolidate_inplace()
138148

139149
# TODO: GH#33198 the setting here shoudlnt need two steps
140-
arr1 = np.random.randn(n_rows, n_cols // 4).astype("f8")
150+
arr1 = np.random.randn(n_rows, max(n_cols // 4, 3)).astype("f8")
141151
arr2 = np.random.randn(n_rows, n_cols // 2).astype("i8")
142152
arr3 = np.random.randn(n_rows, n_cols // 4).astype("f8")
143153
df2 = pd.concat(
@@ -151,11 +161,11 @@ def setup(self, op):
151161
self.left = df
152162
self.right = df2
153163

154-
def time_op_different_blocks(self, op):
164+
def time_op_different_blocks(self, op, shape):
155165
# blocks (and dtypes) are not aligned
156166
op(self.left, self.right)
157167

158-
def time_op_same_blocks(self, op):
168+
def time_op_same_blocks(self, op, shape):
159169
# blocks (and dtypes) are aligned
160170
op(self.left, self.left)
161171

0 commit comments

Comments
 (0)