From f05cd55995427e76853fe79e8409c8b5e91c8e84 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 15 Aug 2021 18:52:57 -0700 Subject: [PATCH] BENCH: fix misleading json asvs --- asv_bench/benchmarks/io/json.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/asv_bench/benchmarks/io/json.py b/asv_bench/benchmarks/io/json.py index d9d27ce7e5d8c..d1468a238c491 100644 --- a/asv_bench/benchmarks/io/json.py +++ b/asv_bench/benchmarks/io/json.py @@ -172,15 +172,19 @@ def time_to_json(self, orient, frame): def peakmem_to_json(self, orient, frame): getattr(self, frame).to_json(self.fname, orient=orient) - def time_to_json_wide(self, orient, frame): + +class ToJSONWide(ToJSON): + def setup(self, orient, frame): + super().setup(orient, frame) base_df = getattr(self, frame).copy() - df = concat([base_df.iloc[:100]] * 1000, ignore_index=True, axis=1) - df.to_json(self.fname, orient=orient) + df_wide = concat([base_df.iloc[:100]] * 1000, ignore_index=True, axis=1) + self.df_wide = df_wide + + def time_to_json_wide(self, orient, frame): + self.df_wide.to_json(self.fname, orient=orient) def peakmem_to_json_wide(self, orient, frame): - base_df = getattr(self, frame).copy() - df = concat([base_df.iloc[:100]] * 1000, ignore_index=True, axis=1) - df.to_json(self.fname, orient=orient) + self.df_wide.to_json(self.fname, orient=orient) class ToJSONISO(BaseIO):