-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ASV/CLN: cleanup period benchmarks #18275
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
Changes from 5 commits
010e80d
b6551f7
41ec6e0
4c8e8e2
e19d397
27d75c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,141 +3,128 @@ | |
|
||
|
||
class PeriodProperties(object): | ||
def setup(self): | ||
self.per = Period('2012-06-01', freq='M') | ||
params = ['M', 'min'] | ||
param_names = ['freq'] | ||
|
||
def setup(self, freq): | ||
self.per = Period('2012-06-01', freq=freq) | ||
|
||
def time_year(self): | ||
def time_year(self, freq): | ||
self.per.year | ||
|
||
def time_month(self): | ||
def time_month(self, freq): | ||
self.per.month | ||
|
||
def time_quarter(self): | ||
self.per.quarter | ||
|
||
def time_day(self): | ||
def time_day(self, freq): | ||
self.per.day | ||
|
||
def time_hour(self): | ||
def time_hour(self, freq): | ||
self.per.hour | ||
|
||
def time_minute(self): | ||
self.per.second | ||
def time_minute(self, freq): | ||
self.per.minute | ||
|
||
def time_second(self): | ||
def time_second(self, freq): | ||
self.per.second | ||
|
||
def time_leap_year(self): | ||
self.per.is_leapyear | ||
|
||
|
||
class Constructor(object): | ||
goal_time = 0.2 | ||
|
||
def setup(self): | ||
self.rng = date_range('1985', periods=1000) | ||
self.rng2 = date_range('1985', periods=1000).to_pydatetime() | ||
|
||
def time_from_date_range(self): | ||
PeriodIndex(self.rng, freq='D') | ||
|
||
def time_from_pydatetime(self): | ||
PeriodIndex(self.rng2, freq='D') | ||
def time_is_leap_year(self, freq): | ||
self.per.is_leap_year | ||
|
||
def time_quarter(self, freq): | ||
self.per.quarter | ||
|
||
class DataFrame(object): | ||
goal_time = 0.2 | ||
def time_qyear(self, freq): | ||
self.per.qyear | ||
|
||
def setup(self): | ||
self.rng = pd.period_range(start='1/1/1990', freq='S', periods=20000) | ||
self.df = pd.DataFrame(index=range(len(self.rng))) | ||
def time_week(self, freq): | ||
self.per.week | ||
|
||
def time_setitem_period_column(self): | ||
self.df['col'] = self.rng | ||
def time_daysinmonth(self, freq): | ||
self.per.daysinmonth | ||
|
||
def time_dayofweek(self, freq): | ||
self.per.dayofweek | ||
|
||
class Algorithms(object): | ||
goal_time = 0.2 | ||
def time_dayofyear(self, freq): | ||
self.per.dayofyear | ||
|
||
def setup(self): | ||
data = [Period('2011-01', freq='M'), Period('2011-02', freq='M'), | ||
Period('2011-03', freq='M'), Period('2011-04', freq='M')] | ||
self.s = Series(data * 1000) | ||
self.i = PeriodIndex(data, freq='M') | ||
def time_start_time(self, freq): | ||
self.per.start_time | ||
|
||
def time_drop_duplicates_pseries(self): | ||
self.s.drop_duplicates() | ||
def time_end_time(self, freq): | ||
self.per.end_time | ||
|
||
def time_drop_duplicates_pindex(self): | ||
self.i.drop_duplicates() | ||
|
||
def time_value_counts_pseries(self): | ||
self.s.value_counts() | ||
class PeriodUnaryMethods(object): | ||
params = ['M', 'min'] | ||
param_names = ['freq'] | ||
|
||
def time_value_counts_pindex(self): | ||
self.i.value_counts() | ||
def setup(self, freq): | ||
self.per = Period('2012-06-01', freq=freq) | ||
|
||
def time_to_timestamp(self, freq): | ||
self.per.to_timestamp() | ||
|
||
class Properties(object): | ||
def setup(self): | ||
self.per = Period('2017-09-06 08:28', freq='min') | ||
def time_now(self, freq): | ||
self.per.now() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is failing (needs a freq) |
||
|
||
def time_year(self): | ||
self.per.year | ||
def time_asfreq(self, freq): | ||
self.per.asfreq('A') | ||
|
||
def time_month(self): | ||
self.per.month | ||
|
||
def time_day(self): | ||
self.per.day | ||
class PeriodIndexConstructor(object): | ||
goal_time = 0.2 | ||
|
||
def time_hour(self): | ||
self.per.hour | ||
params = ['D'] | ||
param_names = ['freq'] | ||
|
||
def time_minute(self): | ||
self.per.minute | ||
def setup(self, freq): | ||
self.rng = date_range('1985', periods=1000) | ||
self.rng2 = date_range('1985', periods=1000).to_pydatetime() | ||
|
||
def time_second(self): | ||
self.per.second | ||
def time_from_date_range(self, freq): | ||
PeriodIndex(self.rng, freq=freq) | ||
|
||
def time_is_leap_year(self): | ||
self.per.is_leap_year | ||
def time_from_pydatetime(self, freq): | ||
PeriodIndex(self.rng2, freq=freq) | ||
|
||
def time_quarter(self): | ||
self.per.quarter | ||
|
||
def time_qyear(self): | ||
self.per.qyear | ||
class DataFramePeriodColumn(object): | ||
goal_time = 0.2 | ||
|
||
def time_week(self): | ||
self.per.week | ||
def setup_cache(self): | ||
rng = pd.period_range(start='1/1/1990', freq='S', periods=20000) | ||
df = pd.DataFrame(index=range(len(rng))) | ||
return rng, df | ||
|
||
def time_daysinmonth(self): | ||
self.per.daysinmonth | ||
def time_setitem_period_column(self, tup): | ||
rng, df = tup | ||
df['col'] = rng | ||
|
||
def time_dayofweek(self): | ||
self.per.dayofweek | ||
|
||
def time_dayofyear(self): | ||
self.per.dayofyear | ||
class Algorithms(object): | ||
goal_time = 0.2 | ||
|
||
def time_start_time(self): | ||
self.per.start_time | ||
params = ['index', 'series'] | ||
param_names = ['typ'] | ||
|
||
def time_end_time(self): | ||
self.per.end_time | ||
def setup(self, typ): | ||
data = [Period('2011-01', freq='M'), Period('2011-02', freq='M'), | ||
Period('2011-03', freq='M'), Period('2011-04', freq='M')] | ||
|
||
def time_to_timestamp(): | ||
self.per.to_timestamp() | ||
if typ == 'index': | ||
self.vector = PeriodIndex(data, freq='M') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would do here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to make that change, but the *1000 for series was there when I got here. Im implicitly assuming someone had a reason for doing it that way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there was a reason |
||
elif typ == 'series': | ||
self.vector = Series(data * 1000) | ||
|
||
def time_now(): | ||
self.per.now() | ||
def time_drop_duplicates(self, typ): | ||
self.vector.drop_duplicates() | ||
|
||
def time_asfreq(): | ||
self.per.asfreq('A') | ||
def time_value_counts(self, typ): | ||
self.vector.value_counts() | ||
|
||
|
||
class period_standard_indexing(object): | ||
class Indexing(object): | ||
goal_time = 0.2 | ||
|
||
def setup(self): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this have to be double brackets ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in my admittedly-limited experience. Though the only examples that use both
params
andparam_names
do have 2+ param_names, so do have double double-brackets forparams
.