From 25ce750ea2ce876a16886dadd3cabb853f00c3d9 Mon Sep 17 00:00:00 2001 From: Philipp Hoffmann Date: Fri, 5 Apr 2024 21:11:44 +0200 Subject: [PATCH 1/4] make input range for np_datetime.c benchmark more realistic --- asv_bench/benchmarks/tslibs/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/tslibs/fields.py b/asv_bench/benchmarks/tslibs/fields.py index 3a2baec54109a..6a3b1822e6a02 100644 --- a/asv_bench/benchmarks/tslibs/fields.py +++ b/asv_bench/benchmarks/tslibs/fields.py @@ -17,7 +17,8 @@ class TimeGetTimedeltaField: param_names = ["size", "field"] def setup(self, size, field): - arr = np.random.randint(0, 10, size=size, dtype="i8") + # 2 days in nanoseconds, scaled up to times e9 for runs with size=seconds + arr = np.random.randint(-2 * 86400 * 1_000_000_000, 0, size=size, dtype="i8") self.i8data = arr def time_get_timedelta_field(self, size, field): From e3aecbee8b96b11f543e4328fb278498e8d8d6d2 Mon Sep 17 00:00:00 2001 From: Philipp Hoffmann Date: Fri, 5 Apr 2024 21:52:45 +0200 Subject: [PATCH 2/4] fix random numbers --- asv_bench/benchmarks/tslibs/fields.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/asv_bench/benchmarks/tslibs/fields.py b/asv_bench/benchmarks/tslibs/fields.py index 6a3b1822e6a02..46ac1f3b36d3e 100644 --- a/asv_bench/benchmarks/tslibs/fields.py +++ b/asv_bench/benchmarks/tslibs/fields.py @@ -73,3 +73,6 @@ def setup(self, size, side, period, freqstr, month_kw): def time_get_start_end_field(self, size, side, period, freqstr, month_kw): get_start_end_field(self.i8data, self.attrname, freqstr, month_kw=month_kw) + + +from .pandas_vb_common import setup # noqa: F401 isort:skip From de11afe3775e5a60b31f6885e76cb9a60f3b69b7 Mon Sep 17 00:00:00 2001 From: Philipp Hoffmann Date: Fri, 5 Apr 2024 22:24:07 +0200 Subject: [PATCH 3/4] fix import --- asv_bench/benchmarks/tslibs/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/tslibs/fields.py b/asv_bench/benchmarks/tslibs/fields.py index 46ac1f3b36d3e..6514007f2c4d5 100644 --- a/asv_bench/benchmarks/tslibs/fields.py +++ b/asv_bench/benchmarks/tslibs/fields.py @@ -75,4 +75,4 @@ def time_get_start_end_field(self, size, side, period, freqstr, month_kw): get_start_end_field(self.i8data, self.attrname, freqstr, month_kw=month_kw) -from .pandas_vb_common import setup # noqa: F401 isort:skip +from ..pandas_vb_common import setup # noqa: F401 isort:skip From 93908498f797e856cfe089c56d723417da0abd91 Mon Sep 17 00:00:00 2001 From: Philipp Hoffmann Date: Sun, 7 Apr 2024 12:34:42 +0200 Subject: [PATCH 4/4] add new benchmark --- asv_bench/benchmarks/tslibs/fields.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/asv_bench/benchmarks/tslibs/fields.py b/asv_bench/benchmarks/tslibs/fields.py index 6514007f2c4d5..fe31879e67a67 100644 --- a/asv_bench/benchmarks/tslibs/fields.py +++ b/asv_bench/benchmarks/tslibs/fields.py @@ -17,13 +17,17 @@ class TimeGetTimedeltaField: param_names = ["size", "field"] def setup(self, size, field): - # 2 days in nanoseconds, scaled up to times e9 for runs with size=seconds - arr = np.random.randint(-2 * 86400 * 1_000_000_000, 0, size=size, dtype="i8") + arr = np.random.randint(0, 10, size=size, dtype="i8") self.i8data = arr + arr = np.random.randint(-86400 * 1_000_000_000, 0, size=size, dtype="i8") + self.i8data_negative = arr def time_get_timedelta_field(self, size, field): get_timedelta_field(self.i8data, field) + def time_get_timedelta_field_negative_td(self, size, field): + get_timedelta_field(self.i8data_negative, field) + class TimeGetDateField: params = [