From 885b17209d61feba9fb5e2b703b48134f3c516a7 Mon Sep 17 00:00:00 2001 From: Brock Date: Sat, 11 Jul 2020 18:46:31 -0700 Subject: [PATCH 1/3] ASV: dt64arr_to_periodarr --- asv_bench/benchmarks/tslibs/period.py | 60 +++++++++++++++++++-------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/asv_bench/benchmarks/tslibs/period.py b/asv_bench/benchmarks/tslibs/period.py index 1a2c89b48c665..b8937428f5595 100644 --- a/asv_bench/benchmarks/tslibs/period.py +++ b/asv_bench/benchmarks/tslibs/period.py @@ -7,9 +7,14 @@ from pandas._libs.tslibs.period import Period, periodarr_to_dt64arr +try: + from pandas._libs.tslibs.vectorized import dt64arr_to_periodarr +except ImportError: + from pandas._libs.tslibs.period import dt64arr_to_periodarr + from pandas.tseries.frequencies import to_offset -from .tslib import _sizes +from .tslib import _sizes, _tzs class PeriodProperties: @@ -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"] @@ -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) From bb0e82eba250297f860ee42d1962a6f08aca496d Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 12 Jul 2020 12:51:05 -0700 Subject: [PATCH 2/3] isort fixup --- asv_bench/benchmarks/tslibs/period.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/asv_bench/benchmarks/tslibs/period.py b/asv_bench/benchmarks/tslibs/period.py index b8937428f5595..1d0b6f1eef729 100644 --- a/asv_bench/benchmarks/tslibs/period.py +++ b/asv_bench/benchmarks/tslibs/period.py @@ -7,14 +7,16 @@ from pandas._libs.tslibs.period import Period, periodarr_to_dt64arr +from pandas.tseries.frequencies import to_offset + +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 -from pandas.tseries.frequencies import to_offset -from .tslib import _sizes, _tzs class PeriodProperties: From 0e3ab507100d6493f1c104fc5d9b6a4b44b47ba7 Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 13 Jul 2020 13:12:02 -0700 Subject: [PATCH 3/3] blackify --- asv_bench/benchmarks/tslibs/period.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/asv_bench/benchmarks/tslibs/period.py b/asv_bench/benchmarks/tslibs/period.py index 1d0b6f1eef729..849e8ec864ac2 100644 --- a/asv_bench/benchmarks/tslibs/period.py +++ b/asv_bench/benchmarks/tslibs/period.py @@ -17,8 +17,6 @@ from pandas._libs.tslibs.period import dt64arr_to_periodarr - - class PeriodProperties: params = (