From f0192af1899b79f1729781263a86cecf6148cfc4 Mon Sep 17 00:00:00 2001 From: Anatoly Myachev Date: Wed, 3 Feb 2021 20:40:54 +0300 Subject: [PATCH] TEST-#2686: add fillna benchmark Signed-off-by: Anatoly Myachev --- asv_bench/benchmarks/benchmarks.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/asv_bench/benchmarks/benchmarks.py b/asv_bench/benchmarks/benchmarks.py index 78254b98471..ce81149a5e0 100644 --- a/asv_bench/benchmarks/benchmarks.py +++ b/asv_bench/benchmarks/benchmarks.py @@ -359,3 +359,29 @@ def setup(self, shape, columns_number, ascending_list): def time_sort_values(self, shape, columns_number, ascending_list): execute(self.df.sort_values(self.columns, ascending=self.ascending)) + + +class TimeFillna: + param_names = ["shape", "limit"] + params = [UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE], [None, 0.8]] + + def setup(self, shape, limit): + columns = [f"col{x}" for x in range(shape[1])] + + if ASV_USE_IMPL == "modin": + self.df = pd.DataFrame( + np.nan, index=pd.RangeIndex(shape[0]), columns=columns + ) + elif ASV_USE_IMPL == "pandas": + self.df = pandas.DataFrame( + np.nan, index=pandas.RangeIndex(shape[0]), columns=columns + ) + else: + raise NotImplementedError + + self.limit = None + if limit: + self.limit = int(limit * shape[0]) + + def time_fillna(self, shape, limit): + execute(self.df.fillna(0, limit=self.limit))