def main(argv): emvm_results = [] py_results = [] sizes = (1, 10, 100, 1000, 10000, 100000, 1000000) for size in sizes: arr = np.array(np.random.random_integers(1, 100, size), dtype='int64') print "array size:", size emvm_result = stopwatch( lambda: br.emvm_count_predicate( is_prime, arr, [is_prime_recursive])) emvm_results.append(emvm_result) print "emvm:", emvm_result py_result = stopwatch(lambda: prime_count_py(arr)) py_results.append(py_result) print "py:", py_result print "" pyplot.plot(sizes, emvm_results, label="EMVM") pyplot.plot(sizes, py_results, label="Python") pyplot.title("Performance comparison: EMVM vs. Python") pyplot.xlabel("Input size") pyplot.ylabel("Runtime (seconds, lower is better)") pyplot.legend() pyplot.savefig("emvm_vs_py_results.pdf") pyplot.savefig("emvm_vs_py_results.png") pyplot.show() return 0
def main(argv): emvm_results = [] py_results = [] sizes = (1, 10, 100, 1000, 10000, 100000, 1000000) for size in sizes: arr = np.array(np.random.random_integers(1, 100, size), dtype='int64') print "array size:", size emvm_result = stopwatch(lambda: br.emvm_count_predicate( is_prime, arr, [is_prime_recursive])) emvm_results.append(emvm_result) print "emvm:", emvm_result py_result = stopwatch(lambda: prime_count_py(arr)) py_results.append(py_result) print "py:", py_result print "" pyplot.plot(sizes, emvm_results, label="EMVM") pyplot.plot(sizes, py_results, label="Python") pyplot.title("Performance comparison: EMVM vs. Python") pyplot.xlabel("Input size") pyplot.ylabel("Runtime (seconds, lower is better)") pyplot.legend() pyplot.savefig("emvm_vs_py_results.pdf") pyplot.savefig("emvm_vs_py_results.png") pyplot.show() return 0
def testCountPredicate(self): arr = np.array([0, 1, 3, 5, 10], dtype='int64') self.assertEquals(3, br.emvm_count_predicate(is_odd, arr), "Incorrect odd count")
def testCountPredicate(self): arr = np.array([0, 1, 3, 5, 10], dtype='int64') self.assertEquals( 3, br.emvm_count_predicate(is_odd, arr), "Incorrect odd count")