def main(input_file, opt_level, pgc): SAVEDCWD = os.getcwd() tests = [] # Lifted from libregr.main regex = re.compile(r'\btest_[a-zA-Z0-9_]+\b') with open(os.path.join(SAVEDCWD, input_file)) as fp: for line in fp: line = line.split('#', 1)[0] line = line.strip() match = regex.search(line) if match is not None: tests.append(match.group()) has_failures = False for test in tests: test_cases = unittest.defaultTestLoader.loadTestsFromName(f"test.{test}") print(f"Testing {test}") for case in test_cases: pyjion.enable() pyjion.enable_tracing() if pgc: pyjion.enable_pgc() print("Enabling PGC") else: pyjion.disable_pgc() print("Disabling PGC") print(f"Trying with Optimizations = {opt_level}") pyjion.set_optimization_level(opt_level) r = unittest.result.TestResult() case.run(r) if r.wasSuccessful(): print(f"All tests in case successful.") else: print(f"Failures occurred.") has_failures = True for failedcase, reason in r.expectedFailures: print(f"---------------------------------------------------------------") print(f"Test case {failedcase} was expected to fail:") print(reason) print(f"---------------------------------------------------------------") for failedcase, reason in r.failures: print(f"---------------------------------------------------------------") print(f"Test case {failedcase} failed:") print(reason) print(f"---------------------------------------------------------------") for failedcase, reason in r.errors: print(f"---------------------------------------------------------------") print(f"Test case {failedcase} failed with errors:") print(reason) print(f"---------------------------------------------------------------") pyjion.disable() gc.collect() return has_failures
self.x = self.x if self.x > other.x else other.x self.y = self.y if self.y > other.y else other.y self.z = self.z if self.z > other.z else other.z return self def maximize(points): next = points[0] for p in points[1:]: next = next.maximize(p) return next def benchmark(n=POINTS): points = [None] * n for i in range(n): points[i] = Point(i) for p in points: p.normalize() return maximize(points) if __name__ == "__main__": print("Float took {0} without Pyjion".format( timeit.repeat(benchmark, repeat=5, number=1), )) pyjion.enable() pyjion.set_optimization_level(1) print("Float took {0} with Pyjion".format( timeit.repeat(benchmark, repeat=5, number=1), )) pyjion.disable()