Fix conftest.py for benchmarks

This commit is contained in:
Roman Yurchak 2018-10-03 14:38:27 +02:00
parent 95379aa043
commit 93c4de6e7c
2 changed files with 28 additions and 4 deletions

View File

@ -0,0 +1,18 @@
#from: http://jakevdp.github.com/blog/2012/08/24/numba-vs-cython/
#setup: import numpy as np ; X = np.linspace(0,10,200).reshape(20,10)
#run: pairwise_loop(X)
#pythran export pairwise_loop(float [][])
import numpy as np
def pairwise_loop(X):
M, N = X.shape
D = np.empty((M,M))
for i in range(M):
for j in range(M):
d = 0.0
for k in range(N):
tmp = X[i,k] - X[j,k]
d += tmp * tmp
D[i,j] = np.sqrt(d)
return D

View File

@ -55,11 +55,14 @@ def _display_driver_logs(browser, driver):
class SeleniumWrapper:
def __init__(self, build_dir, server_port, server_hostname='127.0.0.1',
server_log=None):
def __init__(self, server_port, server_hostname='127.0.0.1',
server_log=None, build_dir=None):
from selenium.webdriver.support.wait import WebDriverWait
from selenium.common.exceptions import TimeoutException
if build_dir is None:
build_dir = BUILD_PATH
driver = self.get_driver()
wait = WebDriverWait(driver, timeout=20)
if not (pathlib.Path(build_dir) / 'test.html').exists():
@ -223,7 +226,10 @@ def web_server_secondary(request):
@contextlib.contextmanager
def spawn_web_server(build_dir):
def spawn_web_server(build_dir=None):
if build_dir is None:
build_dir = BUILD_PATH
tmp_dir = tempfile.mkdtemp()
log_path = pathlib.Path(tmp_dir) / 'http-server.log'
@ -312,7 +318,7 @@ def run_web_server(q, log_filepath, build_dir):
if (__name__ == '__main__'
and multiprocessing.current_process().name == 'MainProcess'
and not hasattr(sys, "_pytest_session")):
with spawn_web_server(BUILD_PATH):
with spawn_web_server():
# run forever
while True:
time.sleep(1)