Skip to content

Commit 70dc98b

Browse files
committed
PERF: add asv benchmarks for .expanding() and .ewm()
1 parent 51e6f60 commit 70dc98b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

asv_bench/benchmarks/rolling.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,40 @@ def setup(self, constructor, window, dtype, method):
2020
def time_rolling(self, constructor, window, dtype, method):
2121
getattr(self.roll, method)()
2222

23+
class ExpandingMethods(object):
24+
25+
sample_time = 0.2
26+
params = (['DataFrame', 'Series'],
27+
['int', 'float'],
28+
['median', 'mean', 'max', 'min', 'std', 'count', 'skew', 'kurt',
29+
'sum'])
30+
param_names = ['contructor', 'window', 'dtype', 'method']
31+
32+
def setup(self, constructor, dtype, method):
33+
N = 10**5
34+
arr = (100 * np.random.random(N)).astype(dtype)
35+
self.expanding = getattr(pd, constructor)(arr).expanding()
36+
37+
def time_expanding(self, constructor, dtype, method):
38+
getattr(self.expanding, method)()
39+
40+
class EWMMethods(object):
41+
42+
sample_time = 0.2
43+
params = (['DataFrame', 'Series'],
44+
[10, 1000],
45+
['int', 'float'],
46+
['mean', 'std'])
47+
param_names = ['contructor', 'window', 'dtype', 'method']
48+
49+
def setup(self, constructor, window, dtype, method):
50+
N = 10**5
51+
arr = (100 * np.random.random(N)).astype(dtype)
52+
self.ewm = getattr(pd, constructor)(arr).ewm(halflife=window)
53+
54+
def time_ewm(self, constructor, window, dtype, method):
55+
getattr(self.ewm, method)()
56+
2357

2458
class VariableWindowMethods(Methods):
2559
sample_time = 0.2

0 commit comments

Comments
 (0)