forked from tobami/codespeed
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsave_single_result.py
More file actions
52 lines (45 loc) · 1.55 KB
/
save_single_result.py
File metadata and controls
52 lines (45 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
####################################################
# Sample script that shows how to save result data #
####################################################
from datetime import datetime
import urllib
import urllib2
# You need to enter the real URL and have the server running
CODESPEED_URL = 'http://localhost:8000/'
current_date = datetime.today()
# Mandatory fields
data = {
'commitid': '14',
'branch': 'default', # Always use default for trunk/master/tip
'project': 'MyProject',
'executable': 'myexe O3 64bits',
'benchmark': 'float',
'environment': "Dual Core",
'result_value': 4000,
}
# Optional fields
data.update({
'revision_date': current_date, # Optional. Default is taken either
# from VCS integration or from current date
'result_date': current_date, # Optional, default is current date
'std_dev': 1.11111, # Optional. Default is blank
'max': 4001.6, # Optional. Default is blank
'min': 3995.1, # Optional. Default is blank
})
def add(data):
params = urllib.urlencode(data)
response = "None"
print "Saving result for executable %s, revision %s, benchmark %s" % (
data['executable'], data['commitid'], data['benchmark'])
try:
f = urllib2.urlopen(CODESPEED_URL + 'result/add/', params)
except urllib2.HTTPError as e:
print str(e)
print e.read()
return
response = f.read()
f.close()
print "Server (%s) response: %s\n" % (CODESPEED_URL, response)
if __name__ == "__main__":
add(data)