Skip to content

Commit f937909

Browse files
ASV: add benchmarks for groupby cython aggregations (#39846)
1 parent f83ce4d commit f937909

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

asv_bench/benchmarks/groupby.py

+23
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,29 @@ def time_dtype_as_field(self, dtype, method, application):
461461
self.as_field_method()
462462

463463

464+
class GroupByCythonAgg:
465+
"""
466+
Benchmarks specifically targetting our cython aggregation algorithms
467+
(using a big enough dataframe with simple key, so a large part of the
468+
time is actually spent in the grouped aggregation).
469+
"""
470+
471+
param_names = ["dtype", "method"]
472+
params = [
473+
["float64"],
474+
["sum", "prod", "min", "max", "mean", "median", "var", "first", "last"],
475+
]
476+
477+
def setup(self, dtype, method):
478+
N = 1_000_000
479+
df = DataFrame(np.random.randn(N, 10), columns=list("abcdefghij"))
480+
df["key"] = np.random.randint(0, 100, size=N)
481+
self.df = df
482+
483+
def time_frame_agg(self, dtype, method):
484+
self.df.groupby("key").agg(method)
485+
486+
464487
class RankWithTies:
465488
# GH 21237
466489
param_names = ["dtype", "tie_method"]

0 commit comments

Comments
 (0)