Skip to content

Commit

Permalink
TEST-modin-project#2722: add util function
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Myskov <alexander.myskov@intel.com>
  • Loading branch information
amyskov committed Feb 12, 2021
1 parent 32bd765 commit 9d8fd85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions asv_bench/benchmarks/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
UNARY_OP_DATA_SIZE,
IMPL,
execute,
get_array_id,
)

# ray init
Expand All @@ -35,7 +36,7 @@ class BaseReadCsv:
def setup_cache(self, test_filename="io_test_file"):
test_filenames = {}
for shape in UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE]:
data_id = "_".join([str(size) for size in shape])
data_id = get_array_id(shape)
test_filenames[data_id] = f"{test_filename}_{data_id}.csv"
df = generate_dataframe("pandas", "str_int", *shape, RAND_LOW, RAND_HIGH)
df.to_csv(test_filenames[data_id], index=False)
Expand All @@ -56,5 +57,8 @@ class TimeReadCsvSkiprows(BaseReadCsv):
]

def time_skiprows(self, test_filenames, shape, skiprows):
data_id = "_".join([str(size) for size in shape])
execute(IMPL[ASV_USE_IMPL].read_csv(test_filenames[data_id], skiprows=skiprows))
execute(
IMPL[ASV_USE_IMPL].read_csv(
test_filenames[get_array_id(shape)], skiprows=skiprows
)
)
4 changes: 4 additions & 0 deletions asv_bench/benchmarks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,7 @@ def random_booleans(number):
def execute(df):
"Make sure the calculations are done."
return df.shape, df.dtypes


def get_array_id(array):
return "_".join([str(element) for element in array])

0 comments on commit 9d8fd85

Please sign in to comment.