[pypy-commit] benchmarks default: turn saveresult.py into a script which can be invoked from the command line

antocuni noreply at buildbot.pypy.org
Wed Jul 20 15:36:29 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r130:0f41c4155021
Date: 2011-07-20 15:36 +0200
http://bitbucket.org/pypy/benchmarks/changeset/0f41c4155021/

Log:	turn saveresult.py into a script which can be invoked from the
	command line

diff --git a/saveresults.py b/saveresults.py
old mode 100644
new mode 100755
--- a/saveresults.py
+++ b/saveresults.py
@@ -1,10 +1,29 @@
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #######################################################
 # This script saves result data                       #
 # It expects the format of unladen swallow's perf.py  #
 #######################################################
+
+"""
+Upload a json file generated by runner.py.
+
+Revision, name and host are required.
+
+Example usage:
+
+  $ ./saveresults.py result.json -r '45757:fabe4fc0dc08' -n pypy-c-jit -H tannit
+  
+  OR
+  
+  $ ./saveresults.py result.json -r '45757:fabe4fc0dc08' -n pypy-c-jit-64 -H tannit
+
+"""
+
+import sys
 import urllib, urllib2
 from datetime import datetime
+import optparse
 
 SPEEDURL = "http://speed.pypy.org/"
 
@@ -79,3 +98,31 @@
     print "saved correctly!\n"
     return 0
 
+
+def main(jsonfile, options):
+    import simplejson
+    with open(jsonfile) as f:
+        data = simplejson.load(f)
+    results = data['results']
+    print 'uploading results...',
+    save('PyPy', options.revision, results, '', options.name, options.host,
+         changed=options.changed)
+    print 'done'
+
+
+if __name__ == '__main__':
+    parser = optparse.OptionParser(usage="%prog result.json [options]")
+    parser.add_option('-r', '--revision', dest='revision', default=None, type=str)
+    parser.add_option('-n', '--name', dest='name', default=None, type=str)
+    parser.add_option('-H', '--host', dest='host', default=None, type=str)
+    parser.add_option('-b', '--baseline', dest='changed', default=True,
+                      action='store_false',
+                      help='upload the results as baseline instead of changed')
+    parser.format_description = lambda fmt: __doc__
+    parser.description = __doc__
+    options, args = parser.parse_args()
+    if options.revision is None or options.name is None or options.host is None or \
+            len(args) != 1:
+        parser.print_help()
+        sys.exit(2)
+    main(args[0], options)


More information about the pypy-commit mailing list