Skip to content
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

TEST-#2690: add astype benchmark #2691

Merged
merged 3 commits into from
Feb 10, 2021
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
23 changes: 22 additions & 1 deletion asv_bench/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

def execute(df):
"Make sure the calculations are done."
return df.shape
return df.shape, df.dtypes


class BaseTimeGroupBy:
Expand Down Expand Up @@ -487,3 +487,24 @@ def setup(self, shape, bins):

def time_value_counts(self, shape, bins):
execute(self.df.value_counts(bins=bins))


class TimeAstype:
param_names = ["shape", "dtype", "astype_ncolumns"]
params = [
UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE],
["float64", "category"],
["one", "all"],
]

def setup(self, shape, dtype, astype_ncolumns):
self.df = generate_dataframe(ASV_USE_IMPL, "int", *shape, RAND_LOW, RAND_HIGH)
if astype_ncolumns == "all":
self.astype_arg = dtype
elif astype_ncolumns == "one":
self.astype_arg = {"col1": dtype}
else:
raise ValueError("astype_ncolumns: {astype_ncolumns} isn't supported")

def time_astype(self, shape, dtype, astype_ncolumns):
execute(self.df.astype(self.astype_arg))