def run(self): # Do not include current directory, validate using installed pythran current_dir = _exclude_current_dir_from_import() os.chdir("pythran/tests") where = os.path.join(current_dir, 'pythran') from pythran import test_compile test_compile() try: import py import xdist args = ["-n", str(self.num_threads), where, '--pep8'] if self.failfast: args.insert(0, '-x') if self.cov: try: import pytest_cov args = ["--cov-report", "html", "--cov-report", "annotate", "--cov", "pythran"] + args except ImportError: print ("W: Skipping coverage analysis, pytest_cov" "not found") if py.test.cmdline.main(args) == 0: print "\\_o<" except ImportError: print ("W: Using only one thread, " "try to install pytest-xdist package") loader = TestLoader() t = TextTestRunner(failfast=self.failfast) t.run(loader.discover(where)) if t.wasSuccessful(): print "\\_o<"
def run(self): import glob import timeit from pythran import test_compile, compile_pythranfile import random import numpy # Do not include current directory, validate using installed pythran current_dir = _exclude_current_dir_from_import() os.chdir("pythran/tests") where = os.path.join(current_dir, 'pythran', 'tests', 'cases') test_compile() candidates = glob.glob(os.path.join(where, '*.py')) sys.path.append(where) random.shuffle(candidates) for candidate in candidates: with file(candidate) as content: runas = [line for line in content.readlines() if line.startswith(BenchmarkCommand.runas_marker)] if runas: modname, _ = os.path.splitext(os.path.basename(candidate)) runas_commands = runas[0].replace( BenchmarkCommand.runas_marker, '').split(";") runas_context = ";".join(["import {0}".format( modname)] + runas_commands[:-1]) runas_command = modname + '.' + runas_commands[-1] # cleaning sopath = os.path.splitext(candidate)[0] + ".so" if os.path.exists(sopath): os.remove(sopath) ti = timeit.Timer(runas_command, runas_context) print(modname + ' running ...') # pythran part if self.mode.startswith('pythran'): cxxflags = ["-O2", "-DNDEBUG", "-DUSE_BOOST_SIMD", "-march=native"] if self.mode == "pythran+omp": cxxflags.append("-fopenmp") begin = time.time() compile_pythranfile(candidate, cxxflags=cxxflags) print('Compilation in : ', (time.time() - begin)) sys.stdout.flush() timing = numpy.array(ti.repeat(self.nb_iter, number=1)) print('median :', numpy.median(timing)) print('min :', numpy.min(timing)) print('max :', numpy.max(timing)) print('std :', numpy.std(timing)) del sys.modules[modname] else: print('* Skip ', candidate, ', no ',end='') print(BenchmarkCommand.runas_marker, ' directive')
def run(self): import glob import timeit # Do not include current directory, validate using installed pythran current_dir = _exclude_current_dir_from_import() os.chdir("pythran/tests") where = os.path.join(current_dir, 'pythran', 'tests', 'cases') from pythran import test_compile, compile_pythranfile test_compile() candidates = glob.glob(os.path.join(where, '*.py')) sys.path.append(where) median = lambda x: sorted(x)[len(x) / 2] for candidate in candidates: with file(candidate) as content: runas = [line for line in content.readlines() if line.startswith(BenchmarkCommand.runas_marker)] if runas: modname, _ = os.path.splitext(os.path.basename(candidate)) runas_commands = runas[0].replace( BenchmarkCommand.runas_marker, '').split(";") runas_context = ";".join(["import {0}".format( modname)] + runas_commands[:-1]) runas_command = modname + '.' + runas_commands[-1] # cleaning sopath = os.path.splitext(candidate)[0] + ".so" if os.path.exists(sopath): os.remove(sopath) ti = timeit.Timer(runas_command, runas_context) # pythran part if self.mode.startswith('pythran'): cxxflags = ["-Ofast", "-DNDEBUG"] if self.mode == "pythran+omp": cxxflags.append("-fopenmp") compile_pythranfile(candidate, cxxflags=cxxflags) print modname + " running ...", sys.stdout.flush() timing = median(ti.repeat(self.nb_iter, number=1)) print timing else: print "* Skip '" + candidate + ', no #runas directive'
def run(self): """ Run tests using the PYTHONPATH path to load pythran. It also check third party library installation before running tests. """ # Do not include current directory, validate using installed pythran current_dir = _exclude_current_dir_from_import() where = os.path.join(current_dir, 'pythran') from pythran import test_compile test_compile() import pytest args = [where] # try a parallel run try: import xdist args = ["-n", str(self.num_threads)] + args except ImportError: print('W: Skipping parallel run, pytest_xdist not found') # try a parallel run try: import pytest_pep8 args = ["--pep8"] + args except ImportError: print('W: Skipping pep8 checks, pytest_pep8 not found') if self.failfast: args.insert(0, '-x') if self.cov: try: # Avoid loading unused module __import__('imp').find_module('pytest_cov') args = ["--cov-report", "html", "--cov-report", "annotate", "--cov", "pythran"] + args except ImportError: print('W: Skipping coverage analysis, pytest_cov' 'not found') if pytest.main(args) == 0: print('\\_o<')
def run(self): """ Run tests using the PYTHONPATH path to load pythran. It also check third party library installation before running tests. """ # Do not include current directory, validate using installed pythran current_dir = _exclude_current_dir_from_import() where = os.path.join(current_dir, 'pythran') from pythran import test_compile test_compile() import pytest args = [where, '--pep8'] # try a parallel run try: import xdist args = ["-n", str(self.num_threads)] + args except ImportError: print('W: Skipping parallel run, pytest_xdist not found') if self.failfast: args.insert(0, '-x') if self.cov: try: # Avoid loading unused module __import__('imp').find_module('pytest_cov') args = [ "--cov-report", "html", "--cov-report", "annotate", "--cov", "pythran" ] + args except ImportError: print('W: Skipping coverage analysis, pytest_cov' 'not found') if pytest.main(args) == 0: print('\\_o<')
def run(self): import glob import timeit from pythran import test_compile, compile_pythranfile import random # Do not include current directory, validate using installed pythran current_dir = _exclude_current_dir_from_import() os.chdir("pythran/tests") where = os.path.join(current_dir, 'pythran', 'tests', 'cases') test_compile() candidates = glob.glob(os.path.join(where, '*.py')) sys.path.append(where) random.shuffle(candidates) for candidate in candidates: with file(candidate) as content: runas = [ line for line in content.readlines() if line.startswith(BenchmarkCommand.runas_marker) ] if runas: modname, _ = os.path.splitext(os.path.basename(candidate)) runas_commands = runas[0].replace( BenchmarkCommand.runas_marker, '').split(";") runas_context = ";".join(["import {0}".format(modname)] + runas_commands[:-1]) runas_command = modname + '.' + runas_commands[-1] # cleaning sopath = os.path.splitext(candidate)[0] + ".so" if os.path.exists(sopath): os.remove(sopath) ti = timeit.Timer(runas_command, runas_context) print(modname + ' running ...') # pythran part if self.mode.startswith('pythran'): cxxflags = [ "-O2", "-DNDEBUG", "-DUSE_BOOST_SIMD", "-march=native" ] if self.mode == "pythran+omp": cxxflags.append("-fopenmp") begin = time.time() compile_pythranfile(candidate, cxxflags=cxxflags) print('Compilation in : ', (time.time() - begin)) sys.stdout.flush() timing = numpy.array(ti.repeat(self.nb_iter, number=1)) print('median :', numpy.median(timing)) print('min :', numpy.min(timing)) print('max :', numpy.max(timing)) print('std :', numpy.std(timing)) del sys.modules[modname] else: print('* Skip ', candidate, ', no ', end='') print(BenchmarkCommand.runas_marker, ' directive')