7
7
import os
8
8
import pandas as pd
9
9
from pandas.core import common as com
10
+ from random import randrange
10
11
11
12
f = '__test__.msg'
12
13
def remove(f):
@@ -15,40 +16,48 @@ def remove(f):
15
16
except:
16
17
pass
17
18
18
- index = date_range('20000101',periods=50000,freq='H')
19
- df = DataFrame({'float1' : randn(50000),
20
- 'float2' : randn(50000)},
19
+ N=100000
20
+ C=5
21
+ index = date_range('20000101',periods=N,freq='H')
22
+ df = DataFrame(dict([ ("float{0}".format(i),randn(N)) for i in range(C) ]),
21
23
index=index)
24
+
25
+ N=100000
26
+ C=5
27
+ index = date_range('20000101',periods=N,freq='H')
28
+ df2 = DataFrame(dict([ ("float{0}".format(i),randn(N)) for i in range(C) ]),
29
+ index=index)
30
+ df2['object'] = ['%08x'%randrange(16**8) for _ in range(N)]
22
31
remove(f)
23
32
"""
24
33
25
34
#----------------------------------------------------------------------
26
35
# msgpack
27
36
28
37
setup = common_setup + """
29
- df .to_msgpack(f)
38
+ df2 .to_msgpack(f)
30
39
"""
31
40
32
41
packers_read_pack = Benchmark ("pd.read_msgpack(f)" , setup , start_date = start_date )
33
42
34
43
setup = common_setup + """
35
44
"""
36
45
37
- packers_write_pack = Benchmark ("df .to_msgpack(f)" , setup , cleanup = "remove(f)" , start_date = start_date )
46
+ packers_write_pack = Benchmark ("df2 .to_msgpack(f)" , setup , cleanup = "remove(f)" , start_date = start_date )
38
47
39
48
#----------------------------------------------------------------------
40
49
# pickle
41
50
42
51
setup = common_setup + """
43
- df .to_pickle(f)
52
+ df2 .to_pickle(f)
44
53
"""
45
54
46
55
packers_read_pickle = Benchmark ("pd.read_pickle(f)" , setup , start_date = start_date )
47
56
48
57
setup = common_setup + """
49
58
"""
50
59
51
- packers_write_pickle = Benchmark ("df .to_pickle(f)" , setup , cleanup = "remove(f)" , start_date = start_date )
60
+ packers_write_pickle = Benchmark ("df2 .to_pickle(f)" , setup , cleanup = "remove(f)" , start_date = start_date )
52
61
53
62
#----------------------------------------------------------------------
54
63
# csv
@@ -68,29 +77,29 @@ def remove(f):
68
77
# hdf store
69
78
70
79
setup = common_setup + """
71
- df .to_hdf(f,'df')
80
+ df2 .to_hdf(f,'df')
72
81
"""
73
82
74
83
packers_read_hdf_store = Benchmark ("pd.read_hdf(f,'df')" , setup , start_date = start_date )
75
84
76
85
setup = common_setup + """
77
86
"""
78
87
79
- packers_write_hdf_store = Benchmark ("df .to_hdf(f,'df')" , setup , cleanup = "remove(f)" , start_date = start_date )
88
+ packers_write_hdf_store = Benchmark ("df2 .to_hdf(f,'df')" , setup , cleanup = "remove(f)" , start_date = start_date )
80
89
81
90
#----------------------------------------------------------------------
82
91
# hdf table
83
92
84
93
setup = common_setup + """
85
- df .to_hdf(f,'df',table=True)
94
+ df2 .to_hdf(f,'df',table=True)
86
95
"""
87
96
88
97
packers_read_hdf_table = Benchmark ("pd.read_hdf(f,'df')" , setup , start_date = start_date )
89
98
90
99
setup = common_setup + """
91
100
"""
92
101
93
- packers_write_hdf_table = Benchmark ("df .to_hdf(f,'df',table=True)" , setup , cleanup = "remove(f)" , start_date = start_date )
102
+ packers_write_hdf_table = Benchmark ("df2 .to_hdf(f,'df',table=True)" , setup , cleanup = "remove(f)" , start_date = start_date )
94
103
95
104
#----------------------------------------------------------------------
96
105
# json
0 commit comments