Skip to content

ASV: dt64arr_to_periodarr #35244

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 3 commits into from
Jul 14, 2020
Merged
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
60 changes: 42 additions & 18 deletions asv_bench/benchmarks/tslibs/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

from pandas.tseries.frequencies import to_offset

from .tslib import _sizes
from .tslib import _sizes, _tzs

try:
from pandas._libs.tslibs.vectorized import dt64arr_to_periodarr
except ImportError:
from pandas._libs.tslibs.period import dt64arr_to_periodarr


class PeriodProperties:
Expand Down Expand Up @@ -75,26 +80,29 @@ def time_period_constructor(self, freq, is_offset):
Period("2012-06-01", freq=freq)


_freq_ints = [
1000,
1011, # Annual - November End
2000,
2011, # Quarterly - November End
3000,
4000,
4006, # Weekly - Saturday End
5000,
6000,
7000,
8000,
9000,
10000,
11000,
12000,
]


class TimePeriodArrToDT64Arr:
params = [
_sizes,
[
1000,
1011, # Annual - November End
2000,
2011, # Quarterly - November End
3000,
4000,
4006, # Weekly - Saturday End
5000,
6000,
7000,
8000,
9000,
10000,
11000,
12000,
],
_freq_ints,
]
param_names = ["size", "freq"]

Expand All @@ -104,3 +112,19 @@ def setup(self, size, freq):

def time_periodarray_to_dt64arr(self, size, freq):
periodarr_to_dt64arr(self.i8values, freq)


class TimeDT64ArrToPeriodArr:
params = [
_sizes,
_freq_ints,
_tzs,
]
param_names = ["size", "freq", "tz"]

def setup(self, size, freq, tz):
arr = np.arange(10, dtype="i8").repeat(size // 10)
self.i8values = arr

def time_dt64arr_to_periodarr(self, size, freq, tz):
dt64arr_to_periodarr(self.i8values, freq, tz)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to time the public function/method that in the end uses this instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its possible, yes. but ATM im aiming for thorough coverage of tslibs in isolation, and PRs that dont touch tslibs can skip any of their asvs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we likely already have coverage at a higher level, these fine-grained asv's are useful.