Skip to content

Commit

Permalink
ASV: dt64arr_to_periodarr (#35244)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored Jul 14, 2020
1 parent 93a4383 commit e5dcdd1
Showing 1 changed file with 42 additions and 18 deletions.
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)

0 comments on commit e5dcdd1

Please sign in to comment.