[pypy-svn] r71213 - codespeed/tools
tobami at codespeak.net
tobami at codespeak.net
Sat Feb 13 10:49:14 CET 2010
Author: tobami
Date: Sat Feb 13 10:49:12 2010
New Revision: 71213
Added:
codespeed/tools/import_from_json.py
Modified:
codespeed/tools/save_result.py
Log:
new tool to import result data from json files
Added: codespeed/tools/import_from_json.py
==============================================================================
--- (empty file)
+++ codespeed/tools/import_from_json.py Sat Feb 13 10:49:12 2010
@@ -0,0 +1,104 @@
+# -*- coding: utf-8 -*-
+import simplejson, urllib, urllib2, pprint
+import sys
+from xml.dom.minidom import parse
+from datetime import datetime
+
+RESULTS_URL = 'http://buildbot.pypy.org/bench_results/'
+SPEEDURL = 'http://localhost:8080/'# This will be pyspeed.pypy.org/
+SAVE_CPYTHON = False
+START_REV = 71154
+
+def saveresult(data):
+ params = urllib.urlencode(data)
+ f = None
+ response = "None"
+ print "Interpreter %s, revision %s, benchmark %s" % (data['interpreter_name'], data['revision_number'], data['benchmark_name'])
+ try:
+ f = urllib2.urlopen(SPEEDURL + 'result/add/', params)
+ response = f.read()
+ f.close()
+ except urllib2.URLError, e:
+ if hasattr(e, 'reason'):
+ response = '\n We failed to reach a server\n'
+ response += ' Reason: ' + str(e.reason)
+ elif hasattr(e, 'code'):
+ response = '\n The server couldn\'t fulfill the request\n'
+ response += ' Error code: ' + str(e)
+ print "Server (%s) response: %s\n" % (SPEEDURL, response)
+
+# get json filenames
+filelist = []
+try:
+ datasource = urllib2.urlopen(RESULTS_URL)
+ dom = parse(datasource)
+ for elem in dom.getElementsByTagName('td'):
+ for e in elem.childNodes:
+ if len(e.childNodes):
+ filename = e.firstChild.toxml()
+ if e.tagName == "a" and ".json" in filename:
+ if int(filename.replace(".json", "")) >= START_REV:
+ filelist.append(filename)
+ datasource.close()
+except urllib2.URLError, e:
+ response = "None"
+ if hasattr(e, 'reason'):
+ response = '\n We failed to reach ' + RESULTS_URL + '\n'
+ response += ' Reason: ' + str(e.reason)
+ elif hasattr(e, 'code'):
+ response = '\n The server couldn\'t fulfill the request\n'
+ response += ' Error code: ' + str(e)
+ print "Results Server (%s) response: %s\n" % (RESULTS_URL, response)
+ sys.exit(1)
+
+# read json result and save to speed.pypy.org
+for filename in filelist:
+ print "Reading %s..." % filename
+ f = urllib2.urlopen(RESULTS_URL + filename)
+ result = simplejson.load(f)
+ current_date = datetime.today()
+ proj = 'pypy'
+ revision = result['revision']
+ interpreter = "pypy-c-jit"
+ int_options = "gc=hybrid"
+ if result.has_key('branch'):
+ if result['branch'] != 'trunk':
+ interpreter = result['branch']
+ int_options = ""
+ if SAVE_CPYTHON:
+ proj = 'cpython'
+ interpreter = 'cpython'
+ int_options = 'default'
+ revision = 262
+
+ for b in result['results']:
+ bench_name = b[0]
+ res_type = b[1]
+ results = b[2]
+ value = 0
+ if res_type == "SimpleComparisonResult":
+ if SAVE_CPYTHON:
+ value = results['base_time']
+ else:
+ value = results['changed_time']
+ elif res_type == "ComparisonResult":
+ if SAVE_CPYTHON:
+ value = results['avg_base']
+ else:
+ value = results['avg_changed']
+ else:
+ print "ERROR: result type unknown", b[1]
+ sys.exit(1)
+ data = {
+ 'revision_number': revision,
+ 'revision_project': proj,
+ 'interpreter_name': interpreter,
+ 'interpreter_coptions': int_options,
+ 'benchmark_name': bench_name,
+ 'environment': "Dual Core Linux",
+ 'result_value': value,
+ 'result_date': current_date,
+ }
+ saveresult(data)
+ f.close()
+print "\nOK"
Modified: codespeed/tools/save_result.py
==============================================================================
--- codespeed/tools/save_result.py (original)
+++ codespeed/tools/save_result.py Sat Feb 13 10:49:12 2010
@@ -2,30 +2,39 @@
from datetime import datetime
import urllib, urllib2
-BASEURL = 'http://localhost:8080/'# This will be pyspeed.pypy.org/
+SPEEDURL = 'http://localhost:8080/'# This will be pyspeed.pypy.org/
-def add_result():
- data = {
- 'revision_number': '23238',
- 'revision_project': 'pypy',
- 'revision_date': "2009-11-15 18:11:29", # Optional. Make mandatory?
- 'interpreter_name': 'pypy-c-jit',
- 'interpreter_coptions': 'gc=Boehm',
- 'benchmark_name': 'Richards',
- 'benchmark_type': 'P',# Optional. Default is T for Trunk. (Trunk, Debug, Python, Multilanguage)
- 'environment': "Dual Core Linux",
- 'result_key': 'total',
- 'result_value': 400,
- 'result_type': 'M',# Optional. Default is 'T' for Time in milliseconds. (Time, Memory, Score)
- 'result_date': datetime.today(),
- }
-
- # TODO add HTTPError try
+data = {
+ 'revision_number': '23238',
+ 'revision_project': 'pypy',
+ 'revision_date': "2009-11-15 18:11:29", # Optional. Make mandatory?
+ 'interpreter_name': 'pypy-c-jit',
+ 'interpreter_coptions': 'gc=Hybrid',
+ 'benchmark_name': 'Richards',
+ 'benchmark_type': 'P',# Optional. Default is T for Trunk. (Trunk, Debug, Python, Multilanguage)
+ 'environment': "Dual Core Linux",
+ 'result_value': 400,
+ 'result_type': 'M',# Optional. Default is 'T' for Time in milliseconds. (Time, Memory, Score)
+ 'result_date': datetime.today(),
+}
+
+def add(data):
params = urllib.urlencode(data)
- f = urllib2.urlopen(BASEURL + 'result/add/', params)
- response = f.read()
- print "Server response:", response
- f.close()
+ f = None
+ response = "None"
+ print "Interpreter %s, revision %s, benchmark %s" % (data['interpreter_name'], data['revision_number'], data['benchmark_name'])
+ try:
+ f = urllib2.urlopen(SPEEDURL + 'result/add/', params)
+ response = f.read()
+ f.close()
+ except urllib2.URLError, e:
+ if hasattr(e, 'reason'):
+ response = '\n We failed to reach a server\n'
+ response += ' Reason: ' + str(e.reason)
+ elif hasattr(e, 'code'):
+ response = '\n The server couldn\'t fulfill the request\n'
+ response += ' Error code: ' + str(e)
+ print "Server (%s) response: %s\n" % (SPEEDURL, response)
if __name__ == "__main__":
- add_result()
+ add_result(data)
More information about the Pypy-commit
mailing list