Skip to content

Commit 5cd4cb2

Browse files
mroeschkejreback
authored andcommitted
CLN: ASV ctors benchmark (#18479)
1 parent 467ee2b commit 5cd4cb2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

asv_bench/benchmarks/ctors.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
from .pandas_vb_common import *
1+
import numpy as np
2+
from pandas import DataFrame, Series, Index, DatetimeIndex, Timestamp
23

34

45
class Constructors(object):
6+
57
goal_time = 0.2
68

79
def setup(self):
8-
self.arr = np.random.randn(100, 100)
10+
N = 10**2
11+
np.random.seed(1234)
12+
self.arr = np.random.randn(N, N)
913
self.arr_str = np.array(['foo', 'bar', 'baz'], dtype=object)
1014

11-
self.data = np.random.randn(100)
12-
self.index = Index(np.arange(100))
15+
self.data = np.random.randn(N)
16+
self.index = Index(np.arange(N))
1317

14-
self.s = Series(([Timestamp('20110101'), Timestamp('20120101'),
15-
Timestamp('20130101')] * 1000))
18+
self.s = Series([Timestamp('20110101'), Timestamp('20120101'),
19+
Timestamp('20130101')] * N * 10)
1620

1721
def time_frame_from_ndarray(self):
1822
DataFrame(self.arr)
1923

2024
def time_series_from_ndarray(self):
21-
pd.Series(self.data, index=self.index)
25+
Series(self.data, index=self.index)
2226

2327
def time_index_from_array_string(self):
2428
Index(self.arr_str)
2529

2630
def time_dtindex_from_series(self):
2731
DatetimeIndex(self.s)
2832

29-
def time_dtindex_from_series2(self):
33+
def time_dtindex_from_index_with_series(self):
3034
Index(self.s)

0 commit comments

Comments
 (0)