Fix benchmark plot. Don't include Numpy import in benchmark timing.

This commit is contained in:
Michael Droettboom 2018-04-11 08:51:41 -04:00
parent 0aeec6702c
commit 35a684271b
2 changed files with 3 additions and 2 deletions

View File

@ -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:

View File

@ -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