From 35a684271bbc4425a46b9f228cb07debd7360129 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 11 Apr 2018 08:51:41 -0400 Subject: [PATCH] Fix benchmark plot. Don't include Numpy import in benchmark timing. --- Makefile | 2 +- benchmark/benchmark.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 41ec13105..67f4e4c92 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ test: all build/test.html benchmark: all build/test.html python benchmark/benchmark.py $(HOSTPYTHON) build/benchmarks.json - python benchmark/plot_benchmark.py benchmarks.json build/benchmarks.png + python benchmark/plot_benchmark.py build/benchmarks.json build/benchmarks.png clean: diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index c73417b4c..41cec248e 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -70,11 +70,12 @@ def get_numpy_benchmarks(): continue content = parse_numpy_benchmark(os.path.join(root, filename)) content += ( + "import numpy as np\n" + "_ = np.empty(())\n" "setup = setup + '\\nfrom __main__ import {}'\n" "from timeit import Timer\n" "t = Timer(run, setup)\n" "r = t.repeat(11, 40)\n" - "import numpy as np\n" "print(np.mean(r))\n".format(name)) yield name, content