Skip to content

Commit

Permalink
BENCH: add benchmarks for cached Index properties
Browse files Browse the repository at this point in the history
  • Loading branch information
qwhelan committed Jul 14, 2019
1 parent 71908cd commit e7b6c75
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions asv_bench/benchmarks/index_cached_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import pandas as pd


class _IndexCache:
number = 1
repeat = (3, 100, 20)

def time_values(self):
self.idx._values

def time_shape(self):
self.idx.shape

def time_is_monotonic(self):
self.idx.is_monotonic

def time_is_monotonic_decreasing(self):
self.idx.is_monotonic_decreasing

def time_is_monotonic_increasing(self):
self.idx.is_monotonic_increasing

def time_is_unique(self):
self.idx.is_unique

def time_engine(self):
self.idx._engine

def time_inferred_type(self):
self.idx.inferred_type

def time_is_all_dates(self):
self.idx.is_all_dates


class MultiIndexCached(_IndexCache):
def setup(self):
self.idx = pd.MultiIndex.from_product(
[pd.date_range("1/1/2000", end="1/1/2001", freq="T"), ["a", "b", "c"]]
)
self.idx._cache = {}


class DatetimeIndex(_IndexCache):
def setup(self):
self.idx = pd.date_range("1/1/2000", end="1/1/2001", freq="T")
self.idx._cache = {}


class PeriodIndex(_IndexCache):
def setup(self):
self.idx = pd.period_range("1/1/2000", end="1/1/2001", freq="T")
self.idx._cache = {}


class Int64Index(_IndexCache):
def setup(self):
self.idx = pd.Index(range(100000))
self.idx._cache = {}

0 comments on commit e7b6c75

Please sign in to comment.