[pypy-commit] extradoc extradoc: some benchmark, very informative IMO

fijal noreply at buildbot.pypy.org
Wed Oct 3 17:09:12 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: extradoc
Changeset: r4833:63504cdb16b2
Date: 2012-10-03 10:08 +0200
http://bitbucket.org/pypy/extradoc/changeset/63504cdb16b2/

Log:	some benchmark, very informative IMO

diff --git a/talk/pyconza2012/examples/calls.py b/talk/pyconza2012/examples/calls.py
new file mode 100644
--- /dev/null
+++ b/talk/pyconza2012/examples/calls.py
@@ -0,0 +1,32 @@
+
+import sys, time
+
+def inner(a, b, c):
+    pass
+
+def simple_call(a, b, c):
+    inner(a, b, c)
+
+def simple_call2(a, b, c):
+    inner(a, c=c, b=b)
+
+def star_call(a, b, c):
+    inner(*(a, b, c))
+
+def star_call_complex(a, b, c):
+    inner(*(a, b), **{'c': c})
+
+def abomination(a, b, c):
+    inner(**locals())
+
+def run(func):
+    count = int(sys.argv[1])
+    t0 = time.time()
+    for i in range(count):
+        func(i, i, i)
+    tk = time.time()
+    t = (tk - t0) / count
+    print "%.2e per call, %d cycles" % (t, int(t * 1.7e9))
+
+for f in [simple_call, simple_call2, star_call, star_call_complex, abomination]:
+    run(f)


More information about the pypy-commit mailing list