Author: Maciej Fijalkowski <[email protected]> Branch: Changeset: r305:7a35d603a9fd Date: 2015-02-21 18:03 +0200 http://bitbucket.org/pypy/benchmarks/changeset/7a35d603a9fd/
Log: add graph alloc removal bench diff --git a/warmup/pypy-graph-alloc-removal.py b/warmup/pypy-graph-alloc-removal.py new file mode 100644 --- /dev/null +++ b/warmup/pypy-graph-alloc-removal.py @@ -0,0 +1,43 @@ +from rpython.translator.interactive import Translation +from rpython.translator.translator import graphof +from rpython.translator.backendopt.malloc import LLTypeMallocRemover +from rpython.flowspace.model import copygraph + +import time + +class X(object): + pass + +def f(n): + x = X() + x.attr = n + y = X() + y.attr = 6 if n > 100 else 5 + return x.attr + y.attr + + +t = Translation(f, [int]) +t.annotate() +t.rtype() + +graph = graphof(t.context, f) + +def main(graph, repeat): + start = time.time() + l = [] + for i in range(repeat): + print i + l.append(f(graph)) + print l + end = time.time() + print end - start + +def f(graph): + start = time.time() + for k in range(10): + g = copygraph(graph) + remover = LLTypeMallocRemover() + remover.remove_mallocs_once(g) + return time.time() - start + +main(graph, 500) _______________________________________________ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
