From bd5b433504795c29437cbe408dd32e87708c2508 Mon Sep 17 00:00:00 2001 From: Christopher Whelan Date: Mon, 10 Jun 2019 11:16:56 -0700 Subject: [PATCH] BENCH: fix noisy asv benchmarks that were running on exhausted generators --- asv_bench/benchmarks/ctors.py | 7 +++++++ asv_bench/benchmarks/frame_ctor.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/asv_bench/benchmarks/ctors.py b/asv_bench/benchmarks/ctors.py index 1c6841a296377..42adede631a01 100644 --- a/asv_bench/benchmarks/ctors.py +++ b/asv_bench/benchmarks/ctors.py @@ -55,7 +55,14 @@ class SeriesConstructors: [False, True], ['float', 'int']] + # Generators get exhausted on use, so run setup before every call + number = 1 + repeat = (3, 250, 10) + def setup(self, data_fmt, with_index, dtype): + if data_fmt in (gen_of_str, gen_of_tuples) and with_index: + raise NotImplementedError('Series constructors do not support ' + 'using generators with indexes') N = 10**4 if dtype == 'float': arr = np.random.randn(N) diff --git a/asv_bench/benchmarks/frame_ctor.py b/asv_bench/benchmarks/frame_ctor.py index 19c2a913e8494..9533938b30fac 100644 --- a/asv_bench/benchmarks/frame_ctor.py +++ b/asv_bench/benchmarks/frame_ctor.py @@ -72,6 +72,10 @@ class FromRecords: params = [None, 1000] param_names = ['nrows'] + # Generators get exhausted on use, so run setup before every call + number = 1 + repeat = (3, 250, 10) + def setup(self, nrows): N = 100000 self.gen = ((x, (x * 20), (x * 100)) for x in range(N))