Skip to content

Commit 1a2512d

Browse files
committed
PERF: add asv benchmarks for .expanding() and .ewm()
1 parent 3a21237 commit 1a2512d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

asv_bench/benchmarks/rolling.py

+36
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,42 @@ def time_rolling(self, constructor, window, dtype, method):
2121
getattr(self.roll, method)()
2222

2323

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

0 commit comments

Comments
 (0)