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

FEAT-#2675: Added benchmark for sort_values #2676

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
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
32 changes: 31 additions & 1 deletion asv_bench/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
import numpy as np
import pandas

from .utils import generate_dataframe, RAND_LOW, RAND_HIGH, random_string
from .utils import (
generate_dataframe,
RAND_LOW,
RAND_HIGH,
random_string,
random_columns,
random_booleans,
)
from modin.config import NPartitions

try:
Expand Down Expand Up @@ -325,3 +332,26 @@ def time_apply(self, data_size, axis):

def time_mean(self, data_size, axis):
execute(self.df.mean(axis=axis))


class TimeSortValues:
param_names = ["data_size", "columns_number", "ascending_list"]
params = [
UNARY_OP_DATA_SIZE,
[1, 2, 10, 100],
[False, True],
]

def setup(self, data_size, columns_number, ascending_list):
self.df = generate_dataframe(
ASV_USE_IMPL, "int", data_size[1], data_size[0], RAND_LOW, RAND_HIGH
)
self.columns = random_columns(self.df.columns, columns_number)
self.ascending = (
random_booleans(columns_number)
if ascending_list
else bool(random_booleans(1)[0])
)

def time_sort_values(self, data_size, columns_number, ascending_list):
execute(self.df.sort_values(self.columns, ascending=self.ascending))
8 changes: 8 additions & 0 deletions asv_bench/benchmarks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ def generate_dataframe(impl, data_type, ncols, nrows, rand_low, rand_high):

def random_string():
return str(uuid.uuid1())


def random_columns(df_columns, columns_number):
return list(random_state.choice(df_columns, size=columns_number))


def random_booleans(number):
return list(random_state.choice([True, False], size=number))