Skip to content

ASV: tslibs.fields #35149

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 6 commits into from
Jul 8, 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
74 changes: 74 additions & 0 deletions asv_bench/benchmarks/tslibs/fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import numpy as np

from pandas._libs.tslibs.fields import (
get_date_field,
get_start_end_field,
get_timedelta_field,
)

from .tslib import _sizes


class TimeGetTimedeltaField:
params = [
_sizes,
["days", "h", "s", "seconds", "ms", "microseconds", "us", "ns", "nanoseconds"],
]
param_names = ["size", "field"]

def setup(self, size, field):
arr = np.random.randint(0, 10, size=size, dtype="i8")
self.i8data = arr

def time_get_timedelta_field(self, size, field):
get_timedelta_field(self.i8data, field)


class TimeGetDateField:
params = [
_sizes,
[
"Y",
"M",
"D",
"h",
"m",
"s",
"us",
"ns",
"doy",
"dow",
"woy",
"q",
"dim",
"is_leap_year",
],
]
param_names = ["size", "field"]

def setup(self, size, field):
arr = np.random.randint(0, 10, size=size, dtype="i8")
self.i8data = arr

def time_get_date_field(self, size, field):
get_date_field(self.i8data, field)


class TimeGetStartEndField:
params = [
_sizes,
["start", "end"],
["month", "quarter", "year"],
["B", None, "QS"],
[12, 3, 5],
]
param_names = ["size", "side", "period", "freqstr", "month_kw"]

def setup(self, size, side, period, freqstr, month_kw):
arr = np.random.randint(0, 10, size=size, dtype="i8")
self.i8data = arr

self.attrname = f"is_{period}_{side}"

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)