Skip to content

ASV: add frame ops benchmarks for varying n_rows/n_columns ratios #39848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions asv_bench/benchmarks/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,26 @@ class FrameWithFrameWide:
operator.add,
operator.floordiv,
operator.gt,
]
],
[
# (n_rows, n_columns)
(1_000_000, 10),
(100_000, 100),
(10_000, 1000),
(1000, 10_000),
],
]
param_names = ["op"]
param_names = ["op", "shape"]

def setup(self, op):
def setup(self, op, shape):
# we choose dtypes so as to make the blocks
# a) not perfectly match between right and left
# b) appreciably bigger than single columns
n_cols = 2000
n_rows = 500
n_rows, n_cols = shape

if op is operator.floordiv:
# floordiv is much slower than the other operations -> use less data
n_rows = n_rows // 10

# construct dataframe with 2 blocks
arr1 = np.random.randn(n_rows, n_cols // 2).astype("f8")
Expand All @@ -131,7 +141,7 @@ def setup(self, op):
df._consolidate_inplace()

# TODO: GH#33198 the setting here shoudlnt need two steps
arr1 = np.random.randn(n_rows, n_cols // 4).astype("f8")
arr1 = np.random.randn(n_rows, max(n_cols // 4, 3)).astype("f8")
arr2 = np.random.randn(n_rows, n_cols // 2).astype("i8")
arr3 = np.random.randn(n_rows, n_cols // 4).astype("f8")
df2 = pd.concat(
Expand All @@ -145,11 +155,11 @@ def setup(self, op):
self.left = df
self.right = df2

def time_op_different_blocks(self, op):
def time_op_different_blocks(self, op, shape):
# blocks (and dtypes) are not aligned
op(self.left, self.right)

def time_op_same_blocks(self, op):
def time_op_same_blocks(self, op, shape):
# blocks (and dtypes) are aligned
op(self.left, self.left)

Expand Down