Commit 7678c5bf authored by Andrew Gerrand's avatar Andrew Gerrand

godashboard: fix benchmarks page (first pass)

R=rsc
CC=golang-dev
https://golang.org/cl/844044
parent f08ce189
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>Go benchmarks</title> <title>{{benchmark}} - Benchmarks - Go Dashboard</title>
<link rel="stylesheet" type="text/css" href="/static/style.css">
<style>
h1 {
font-size: 1em;
font-weight: bold;
}
h2 {
font-size: 1em;
font-weight: bold;
}
table.alternate {
white-space: nowrap;
}
table.alternate tr td {
padding-right: 10px;
}
table.alternate tr td:last-child {
padding-right: 0;
}
table.alternate tr:nth-child(2n) {
background-color: #f8f8f8;
}
td.revision {
}
span.hash {
font-family: monospace;
font-size: small;
color: #aaa;
}
span.nodeseq {
}
td.user {
font-size: small;
}
td.date {
color: #aaa;
font-size: small;
}
td.result {
text-align: center;
}
span.ok {
}
td.desc {
font-size: small;
font-family: sans-serif;
}
th.builder {
font-weight: bold;
padding-right: 0.5em;
}
</style>
</head> </head>
<body> <body>
<h1>Go dashboard - {{benchmark}}</h1> <ul class="menu">
<li><a href="/">Build Status</a></li>
<a href="/">build status</a> <br> <li><a href="/package">Packages</a></li>
<a href="/benchmarks">benchmarks</a> <li><a href="/benchmarks">Benchmarks</a></li>
<li><a href="http://golang.org/">golang.org</a></li>
</ul>
<h1>Go Dashboard</h1>
<h2>{{benchmark}}</h2> <h2>{{benchmark}}</h2>
<a href="{{benchmark}}?fmt=json">json</a> <a href="{{benchmark}}?fmt=json">json</a>
{% for g in graphs %} {% for g in graphs %}
......
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>Go benchmarks</title> <title>Benchmarks - Go Dashboard</title>
<link rel="stylesheet" type="text/css" href="/static/style.css">
<style>
h1 {
font-size: 1em;
font-weight: bold;
}
h2 {
font-size: 1em;
font-weight: bold;
}
table.alternate {
white-space: nowrap;
}
table.alternate tr td {
padding-right: 10px;
}
table.alternate tr td:last-child {
padding-right: 0;
}
table.alternate tr:nth-child(2n) {
background-color: #f8f8f8;
}
td.revision {
}
span.nodeseq {
}
td.user {
font-size: small;
}
td.date {
color: #aaa;
font-size: small;
}
td.result {
text-align: center;
}
span.ok {
}
td.desc {
font-size: small;
font-family: sans-serif;
}
th.builder {
font-weight: bold;
padding-right: 0.5em;
}
</style>
</head> </head>
<body> <body>
<h1>Go dashboard - benchmarks</h1> <ul class="menu">
<li><a href="/">Build Status</a></li>
<a href="/">build status</a> <li><a href="/package">Packages</a></li>
<li>Benchmarks</li>
<li><a href="http://golang.org/">golang.org</a></li>
</ul>
<h1>Go Dashboard</h1>
<h2>Benchmarks</h2> <h2>Benchmarks</h2>
<table class="alternate" cellpadding="0" cellspacing="0"> <table class="alternate" cellpadding="0" cellspacing="0">
<tr> <tr>
<th></th> <th></th>
...@@ -65,15 +25,17 @@ ...@@ -65,15 +25,17 @@
{% endfor %} {% endfor %}
</tr> </tr>
{% for m in benchmarks %} {% for bm in rows %}
<tr> <tr>
<td class="name"><a href="/benchmarks/{{m.name}}">{{m.name}}</a></td> <td class="name"><a href="/benchmarks/{{bm.name}}">{{bm.name}}</a></td>
{% for b in m.builds %} {% for bl in bm.builders %}
<td class="result"> <td class="result">
{% if b.url %} {% if bl.url %}
<img src="{{b.url}}&chs=80x20&chf=bg,s,00000000&chco=000000ff&chls=1,1,0"> <img src="{{bl.url}}" />
{% endif %} {% else %}
<img src="/benchmarks/single?benchmark={{bm.name}}&builder={{bl.name}}" />
{% endif %}
</td> </td>
{% endfor %} {% endfor %}
</tr> </tr>
......
...@@ -388,25 +388,20 @@ class Benchmarks(webapp.RequestHandler): ...@@ -388,25 +388,20 @@ class Benchmarks(webapp.RequestHandler):
def compute(self, num): def compute(self, num):
benchmarks, builders = benchmark_list() benchmarks, builders = benchmark_list()
# Build empty grid, to be filled in.
rows = [{"name": bm, "builds": [{"url": ""} for b in builders]} for bm in benchmarks]
for i in range(len(rows)): rows = []
benchmark = benchmarks[i] for bm in benchmarks:
builds = rows[i]["builds"] row = {'name':bm, 'builders': []}
minr, maxr, bybuilder = benchmark_data(benchmark) for bl in builders:
for j in range(len(builders)): key = "single-%s-%s" % (bm, bl)
builder = builders[j] url = memcache.get(key)
cell = builds[j] row['builders'].append({'name': bl, 'url': url})
if len(bybuilder) > 0 and builder == bybuilder[0][0]: rows.append(row)
cell["url"] = benchmark_sparkline(bybuilder[0][2])
bybuilder = bybuilder[1:]
path = os.path.join(os.path.dirname(__file__), 'benchmarks.html') path = os.path.join(os.path.dirname(__file__), 'benchmarks.html')
data = { data = {
"benchmarks": rows, "builders": [builderInfo(b) for b in builders],
"builders": [builderInfo(b) for b in builders] "rows": rows,
} }
return template.render(path, data) return template.render(path, data)
...@@ -464,6 +459,34 @@ class Benchmarks(webapp.RequestHandler): ...@@ -464,6 +459,34 @@ class Benchmarks(webapp.RequestHandler):
self.response.set_status(200) self.response.set_status(200)
class SingleBenchmark(webapp.RequestHandler):
"""
Fetch data for single benchmark/builder combination
and return sparkline url as HTTP redirect, also set memcache entry.
"""
def get(self):
benchmark = self.request.get('benchmark')
builder = self.request.get('builder')
key = "single-%s-%s" % (benchmark, builder)
url = memcache.get(key)
if url is None:
minr, maxr, bybuilder = benchmark_data(benchmark)
for bb in bybuilder:
if bb[0] != builder:
continue
url = benchmark_sparkline(bb[2])
if url is None:
self.response.set_status(500, "No data found")
return
memcache.set(key, url, 700) # slightly longer than bench timeout
self.response.set_status(302)
self.response.headers.add_header("Location", url)
def node(num): def node(num):
q = Commit.all() q = Commit.all()
q.filter('num =', num) q.filter('num =', num)
...@@ -535,19 +558,19 @@ def benchmark_sparkline(ns): ...@@ -535,19 +558,19 @@ def benchmark_sparkline(ns):
# Encoding is 0-61, which is fine enough granularity for our tiny graphs. _ means missing. # Encoding is 0-61, which is fine enough granularity for our tiny graphs. _ means missing.
encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
s = ''.join([x < 0 and "_" or encoding[int((len(encoding)-1)*x/m)] for x in ns]) s = ''.join([x < 0 and "_" or encoding[int((len(encoding)-1)*x/m)] for x in ns])
url = "http://chart.apis.google.com/chart?cht=ls&chd=s:"+s url = "http://chart.apis.google.com/chart?cht=ls&chd=s:"+s+"&chs=80x20&chf=bg,s,00000000&chco=000000ff&chls=1,1,0"
return url return url
def benchmark_list(): def benchmark_list():
q = BenchmarkResults.all() q = BenchmarkResults.all()
q.order('__key__') q.order('__key__')
q.filter('builder = ', u'darwin-amd64') q.filter('builder = ', u'darwin-amd64')
benchmarks = [r.benchmark for r in q.fetch(1000)] benchmarks = [r.benchmark for r in q]
q = BenchmarkResults.all() q = BenchmarkResults.all()
q.order('__key__') q.order('__key__')
q.filter('benchmark =', u'math_test.BenchmarkSqrt') q.filter('benchmark =', u'math_test.BenchmarkSqrt')
builders = [r.builder for r in q.fetch(100)] builders = [r.builder for r in q.fetch(20)]
return benchmarks, builders return benchmarks, builders
...@@ -682,6 +705,7 @@ application = webapp.WSGIApplication( ...@@ -682,6 +705,7 @@ application = webapp.WSGIApplication(
('/init', Init), ('/init', Init),
('/build', Build), ('/build', Build),
('/benchmarks', Benchmarks), ('/benchmarks', Benchmarks),
('/benchmarks/single', SingleBenchmark),
('/benchmarks/.*', GetBenchmarks), ('/benchmarks/.*', GetBenchmarks),
], debug=True) ], debug=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment