Skip to content

Commit d8c98df

Browse files
committed
CLN: ASV hdfstore benchmark
1 parent 52fefd5 commit d8c98df

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

asv_bench/benchmarks/hdfstore_bench.py

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1-
from .pandas_vb_common import *
21
import os
32

3+
import numpy as np
4+
from pandas import DataFrame, Panel, date_range, HDFStore
5+
import pandas.util.testing as tm
46

5-
class HDF5(object):
6-
goal_time = 0.2
7-
8-
def setup(self):
9-
self.index = tm.makeStringIndex(25000)
10-
self.df = DataFrame({'float1': randn(25000), 'float2': randn(25000),},
11-
index=self.index)
7+
from .pandas_vb_common import setup # noqa
128

13-
self.df_mixed = DataFrame(
14-
{'float1': randn(25000), 'float2': randn(25000),
15-
'string1': (['foo'] * 25000),
16-
'bool1': ([True] * 25000),
17-
'int1': np.random.randint(0, 250000, size=25000),},
18-
index=self.index)
199

20-
self.df_wide = DataFrame(np.random.randn(25000, 100))
10+
class HDF5(object):
2111

22-
self.df2 = DataFrame({'float1': randn(25000), 'float2': randn(25000)},
23-
index=date_range('1/1/2000', periods=25000))
24-
self.df_wide2 = DataFrame(np.random.randn(25000, 100),
25-
index=date_range('1/1/2000', periods=25000))
12+
goal_time = 0.2
2613

27-
self.df_dc = DataFrame(np.random.randn(10000, 10),
28-
columns=[('C%03d' % i) for i in range(10)])
14+
def setup(self):
15+
N = 25000
16+
index = tm.makeStringIndex(N)
17+
self.df = DataFrame({'float1': np.random.randn(N),
18+
'float2': np.random.randn(N)},
19+
index=index)
20+
self.df_mixed = DataFrame({'float1': np.random.randn(N),
21+
'float2': np.random.randn(N),
22+
'string1': ['foo'] * N,
23+
'bool1': [True] * N,
24+
'int1': np.random.randint(0, N, size=N)},
25+
index=index)
26+
self.df_wide = DataFrame(np.random.randn(N, 100))
27+
self.start_wide = self.df_wide.index[10000]
28+
self.stop_wide = self.df_wide.index[15000]
29+
self.df2 = DataFrame({'float1': np.random.randn(N),
30+
'float2': np.random.randn(N)},
31+
index=date_range('1/1/2000', periods=N))
32+
self.start = self.df2.index[10000]
33+
self.stop = self.df2.index[15000]
34+
self.df_wide2 = DataFrame(np.random.randn(N, 100),
35+
index=date_range('1/1/2000', periods=N))
36+
self.df_dc = DataFrame(np.random.randn(N, 10),
37+
columns=['C%03d' % i for i in range(10)])
2938

3039
self.f = '__test__.h5'
3140
self.remove(self.f)
@@ -82,14 +91,12 @@ def time_write_store_table_dc(self):
8291
self.store.append('table_dc_write', self.df_dc, data_columns=True)
8392

8493
def time_query_store_table_wide(self):
85-
start = self.df_wide2.index[10000]
86-
stop = self.df_wide2.index[15000]
87-
self.store.select('table_wide', where="index > start and index < stop")
94+
self.store.select('table_wide', where="index > self.start_wide and "
95+
"index < self.stop_wide")
8896

8997
def time_query_store_table(self):
90-
start = self.df2.index[10000]
91-
stop = self.df2.index[15000]
92-
self.store.select('table', where="index > start and index < stop")
98+
self.store.select('table', where="index > self.start and "
99+
"index < self.stop")
93100

94101
def time_store_repr(self):
95102
repr(self.store)
@@ -102,14 +109,15 @@ def time_store_info(self):
102109

103110

104111
class HDF5Panel(object):
112+
105113
goal_time = 0.2
106114

107115
def setup(self):
108116
self.f = '__test__.h5'
109-
self.p = Panel(randn(20, 1000, 25),
110-
items=[('Item%03d' % i) for i in range(20)],
117+
self.p = Panel(np.random.randn(20, 1000, 25),
118+
items=['Item%03d' % i for i in range(20)],
111119
major_axis=date_range('1/1/2000', periods=1000),
112-
minor_axis=[('E%03d' % i) for i in range(25)])
120+
minor_axis=['E%03d' % i for i in range(25)])
113121
self.remove(self.f)
114122
self.store = HDFStore(self.f)
115123
self.store.append('p1', self.p)

0 commit comments

Comments
 (0)