Skip to content

Commit dbffba8

Browse files
jorisvandenbosschejreback
authored andcommitted
CLN/ASV clean-up frame stat ops benchmarks (#17205)
1 parent a09db4b commit dbffba8

File tree

1 file changed

+22
-78
lines changed

1 file changed

+22
-78
lines changed

asv_bench/benchmarks/stat_ops.py

+22-78
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,36 @@
11
from .pandas_vb_common import *
22

33

4-
class stat_ops_frame_mean_float_axis_0(object):
5-
goal_time = 0.2
6-
7-
def setup(self):
8-
self.df = DataFrame(np.random.randn(100000, 4))
9-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
10-
11-
def time_stat_ops_frame_mean_float_axis_0(self):
12-
self.df.mean()
13-
14-
15-
class stat_ops_frame_mean_float_axis_1(object):
16-
goal_time = 0.2
17-
18-
def setup(self):
19-
self.df = DataFrame(np.random.randn(100000, 4))
20-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
21-
22-
def time_stat_ops_frame_mean_float_axis_1(self):
23-
self.df.mean(1)
24-
25-
26-
class stat_ops_frame_mean_int_axis_0(object):
27-
goal_time = 0.2
28-
29-
def setup(self):
30-
self.df = DataFrame(np.random.randn(100000, 4))
31-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
32-
33-
def time_stat_ops_frame_mean_int_axis_0(self):
34-
self.dfi.mean()
35-
36-
37-
class stat_ops_frame_mean_int_axis_1(object):
38-
goal_time = 0.2
4+
def _set_use_bottleneck_False():
5+
try:
6+
pd.options.compute.use_bottleneck = False
7+
except:
8+
from pandas.core import nanops
9+
nanops._USE_BOTTLENECK = False
3910

40-
def setup(self):
41-
self.df = DataFrame(np.random.randn(100000, 4))
42-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
43-
44-
def time_stat_ops_frame_mean_int_axis_1(self):
45-
self.dfi.mean(1)
46-
47-
48-
class stat_ops_frame_sum_float_axis_0(object):
49-
goal_time = 0.2
5011

51-
def setup(self):
52-
self.df = DataFrame(np.random.randn(100000, 4))
53-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
54-
55-
def time_stat_ops_frame_sum_float_axis_0(self):
56-
self.df.sum()
57-
58-
59-
class stat_ops_frame_sum_float_axis_1(object):
12+
class FrameOps(object):
6013
goal_time = 0.2
6114

62-
def setup(self):
63-
self.df = DataFrame(np.random.randn(100000, 4))
64-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
15+
param_names = ['op', 'use_bottleneck', 'dtype', 'axis']
16+
params = [['mean', 'sum', 'median'],
17+
[True, False],
18+
['float', 'int'],
19+
[0, 1]]
6520

66-
def time_stat_ops_frame_sum_float_axis_1(self):
67-
self.df.sum(1)
21+
def setup(self, op, use_bottleneck, dtype, axis):
22+
if dtype == 'float':
23+
self.df = DataFrame(np.random.randn(100000, 4))
24+
elif dtype == 'int':
25+
self.df = DataFrame(np.random.randint(1000, size=(100000, 4)))
6826

27+
if not use_bottleneck:
28+
_set_use_bottleneck_False()
6929

70-
class stat_ops_frame_sum_int_axis_0(object):
71-
goal_time = 0.2
72-
73-
def setup(self):
74-
self.df = DataFrame(np.random.randn(100000, 4))
75-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
76-
77-
def time_stat_ops_frame_sum_int_axis_0(self):
78-
self.dfi.sum()
79-
80-
81-
class stat_ops_frame_sum_int_axis_1(object):
82-
goal_time = 0.2
83-
84-
def setup(self):
85-
self.df = DataFrame(np.random.randn(100000, 4))
86-
self.dfi = DataFrame(np.random.randint(1000, size=self.df.shape))
30+
self.func = getattr(self.df, op)
8731

88-
def time_stat_ops_frame_sum_int_axis_1(self):
89-
self.dfi.sum(1)
32+
def time_op(self, op, use_bottleneck, dtype, axis):
33+
self.func(axis=axis)
9034

9135

9236
class stat_ops_level_frame_sum(object):

0 commit comments

Comments
 (0)