[pypy-commit] extradoc extradoc: Add runner.py which does nice averaging and stddev. Also make sqrt compatible.

fijal noreply at buildbot.pypy.org
Tue Jun 14 20:45:43 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: extradoc
Changeset: r3677:c77d0d592c80
Date: 2011-06-14 20:48 +0200
http://bitbucket.org/pypy/extradoc/changeset/c77d0d592c80/

Log:	Add runner.py which does nice averaging and stddev. Also make sqrt
	compatible. Remove -O3 without -fno-tree-vectorize

diff --git a/talk/iwtc11/benchmarks/runall.sh b/talk/iwtc11/benchmarks/runall.sh
--- a/talk/iwtc11/benchmarks/runall.sh
+++ b/talk/iwtc11/benchmarks/runall.sh
@@ -5,7 +5,6 @@
 ./benchmark.sh pypy --jit enable_opts=intbounds:rewrite:virtualize:heap
 ./benchmark.sh gcc
 ./benchmark.sh gcc -O2
-./benchmark.sh gcc -O3 -march=native
 ./benchmark.sh gcc -O3 -march=native -fno-tree-vectorize
 ./benchmark.sh python2.7
 
diff --git a/talk/iwtc11/benchmarks/runner.py b/talk/iwtc11/benchmarks/runner.py
new file mode 100755
--- /dev/null
+++ b/talk/iwtc11/benchmarks/runner.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+""" Usage:
+
+runner.py [-w warmup] [-n times] <file> <extra_args>
+"""
+
+from __future__ import division
+
+import py
+import sys
+import time
+from optparse import OptionParser
+
+def main():
+    parser = OptionParser()
+    parser.add_option('-n', dest='no', help='number of iterations', type=int,
+                      default=10)
+    parser.add_option('-w', dest='warmup', help='number of warmup runs',
+                      type=int, default=0)
+    options, args = parser.parse_args()
+    if args[0].endswith('.py'):
+        mod = py.path.local(args[0]).pyimport()
+        sys.stderr.write("warming up")
+        args = args[1:]
+        for i in range(options.warmup):
+            mod.main(args)
+            sys.stderr.write('.')
+        sys.stderr.write("\n")
+        print >>sys.stderr, "benchmarking"
+        all = []
+        for i in range(options.no):
+            t0 = time.time()
+            mod.main(args)
+            all.append(time.time() - t0)
+            print >>sys.stderr, "Next:", all[-1]
+    else:
+        
+    if n > 1:
+        avg = sum(all) / len(all)
+        stddev = (sum([(i - avg) * (i - avg) for i in all]) / (len(all) - 1)) ** 0.5
+        print "Avg: %s +- %s" % (avg, stddev)
+    else:
+        print "Run: %s" % (all[0],)
+
+if __name__ == '__main__':
+    main()
diff --git a/talk/iwtc11/benchmarks/sqrt/sqrt.py b/talk/iwtc11/benchmarks/sqrt/sqrt.py
--- a/talk/iwtc11/benchmarks/sqrt/sqrt.py
+++ b/talk/iwtc11/benchmarks/sqrt/sqrt.py
@@ -48,3 +48,5 @@
     def __rdiv__(self, other):
         return  Fix16((Fix16(other).val << 16) / self.val, False)
 
+def main(argv):
+    sqrt(eval(argv[0])(123456), 100000000)


More information about the pypy-commit mailing list