Skip to content

CLN: ASV index_object benchmark #18758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions asv_bench/benchmarks/ctors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from pandas import Series, Index, DatetimeIndex, Timestamp
import pandas.util.testing as tm
from pandas import Series, Index, DatetimeIndex, Timestamp, MultiIndex

from .pandas_vb_common import setup # noqa
from .pandas_vb_common import setup # noqa


class SeriesConstructors(object):
Expand All @@ -21,7 +22,6 @@ class SeriesConstructors(object):

def setup(self, data_fmt, with_index):
N = 10**4
np.random.seed(1234)
arr = np.random.randn(N)
self.data = data_fmt(arr)
self.index = np.arange(N) if with_index else None
Expand All @@ -35,21 +35,32 @@ class SeriesDtypesConstructors(object):
goal_time = 0.2

def setup(self):
N = 10**2
N = 10**4
self.arr = np.random.randn(N, N)
self.arr_str = np.array(['foo', 'bar', 'baz'], dtype=object)

self.data = np.random.randn(N)
self.index = Index(np.arange(N))

self.s = Series([Timestamp('20110101'), Timestamp('20120101'),
Timestamp('20130101')] * N * 10)

def time_index_from_array_string(self):
Index(self.arr_str)

def time_index_from_array_floats(self):
Index(self.arr)

def time_dtindex_from_series(self):
DatetimeIndex(self.s)

def time_dtindex_from_index_with_series(self):
Index(self.s)


class MultiIndexConstructor(object):

goal_time = 0.2

def setup(self):
N = 10**4
self.iterables = [tm.makeStringIndex(N), range(20)]

def time_multiindex_from_iterables(self):
MultiIndex.from_product(self.iterables)
Loading