-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BENCH: add benchmarks for cached Index properties
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |