Skip to content

BENCH: Add rolling apply benchmarks #28566

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 2 commits into from
Sep 23, 2019
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
19 changes: 19 additions & 0 deletions asv_bench/benchmarks/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()


class Apply:
params = (
["DataFrame", "Series"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to just put (pd.DataFrame, pd.Series) and avoid the getattr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the nicest way to have it label nicely in the params and not be an if/else in the setup. Plus the getattr is in the setup so it won't impact the benchmark time.

[10, 1000],
["int", "float"],
[sum, np.sum, lambda x: np.sum(x) + 5],
[True, False],
)
param_names = ["contructor", "window", "dtype", "function", "raw"]

def setup(self, constructor, window, dtype, function, raw):
N = 10 ** 5
arr = (100 * np.random.random(N)).astype(dtype)
self.roll = getattr(pd, constructor)(arr).rolling(window)

def time_rolling(self, constructor, window, dtype, function, raw):
self.roll.apply(function, raw=raw)


class ExpandingMethods:

params = (
Expand Down