From db741d36d1c75c309c867ed46a2512dbc9a66c75 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Sat, 21 Sep 2019 20:17:13 -0700 Subject: [PATCH 1/2] BENCH: Add rolling apply benchmarks --- asv_bench/benchmarks/rolling.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/asv_bench/benchmarks/rolling.py b/asv_bench/benchmarks/rolling.py index b42fa553b495c..136ad65b9105c 100644 --- a/asv_bench/benchmarks/rolling.py +++ b/asv_bench/benchmarks/rolling.py @@ -25,6 +25,25 @@ def peakmem_rolling(self, constructor, window, dtype, method): getattr(self.roll, method)() +class Apply: + params = ( + ["DataFrame", "Series"], + [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 = ( From ad4e6bb6dd03978fa86babead76bf4db3a586eae Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Sat, 21 Sep 2019 22:43:07 -0700 Subject: [PATCH 2/2] black --- asv_bench/benchmarks/rolling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/rolling.py b/asv_bench/benchmarks/rolling.py index 136ad65b9105c..493f96d46d5e7 100644 --- a/asv_bench/benchmarks/rolling.py +++ b/asv_bench/benchmarks/rolling.py @@ -31,7 +31,7 @@ class Apply: [10, 1000], ["int", "float"], [sum, np.sum, lambda x: np.sum(x) + 5], - [True, False] + [True, False], ) param_names = ["contructor", "window", "dtype", "function", "raw"]