Download:
child 50:c074bc38b66a
parent 48:ab4996533232
49:98a080b1eb9a
Anton Shestakov <av6@dwimlabs.net>, Sun, 07 Feb 2016 22:32:30 +0800
viewer: add a bit fancier results page with c3.js diagrams

2 файлов изменено, 92 вставок(+), 3 удалений(-) [+]
templates/fancy.html file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/fancy.html Sun Feb 07 22:32:30 2016 +0800
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>hgperfcheck{% if changesets %} (rev {{ changesets[0]['rev'] }} and earlier){% end %}</title>
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet" type="text/css">
+ <style type="text/css">
+ * {
+ font-family: monospace;
+ }
+ </style>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.14/d3.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.js"></script>
+ </head>
+ <body>
+ <header>
+ <p>
+ <a href="{{ setrev() }}">back to tip</a>
+ {% set prevrev = changesets[0]['rev'] + 120 if changesets else None %}
+ {% if prevrev %}<a href="{{ setrev(prevrev) }}">prev page</a>{% end %}
+ {% set nextrev = changesets[-1]['rev'] - 1 if changesets else None %}
+ {% if nextrev > -1 %}<a href="{{ setrev(nextrev) }}">next page</a>{% end %}
+ <span style="color: #777;">
+ hover things for a tooltip; red means slow, green means fast; first
+ color and time means without .hg/cache, second means with .hg/cache.
+ </span>
+ </p>
+ <p>
+ timings:
+ {% for mark, desc in marks.items() %}
+ -<a href="{{ setmarks(remove=mark) }}" title="{{ desc }}">{{ mark }}</a>
+ {% end %}
+ {% for mark, desc in moremarks.items() %}
+ +<a href="{{ setmarks(add=mark) }}" title="{{ desc }}">{{ mark }}</a>
+ {% end %}
+ *<a href="{{ setmarks() }}">all</a>
+ </p>
+ </header>
+ <div id="chart"></div>
+ <footer>
+ <p>
+ <a href="{{ setrev() }}">back to tip</a>
+ {% if prevrev %}<a href="{{ setrev(prevrev) }}">prev page</a>{% end %}
+ {% if nextrev > -1 %}<a href="{{ setrev(nextrev) }}">next page</a>{% end %}
+ </p>
+ </footer>
+
+ <script type="application/json" id="data">{% raw json_encode(data) %}</script>
+ <script>
+ var chart = c3.generate({
+ bindto: '#chart',
+ size: {height: 500},
+ tooltip: {format: {title: function(x) { return x; }}},
+ data: JSON.parse(document.getElementById('data').firstChild.nodeValue)
+ });
+ </script>
+ </body>
+</html>
--- a/viewer.py Sat Feb 06 20:47:42 2016 +0800
+++ b/viewer.py Sun Feb 07 22:32:30 2016 +0800
@@ -50,13 +50,15 @@
class ResultsHandler(BaseHandler):
- def get(self, ext):
+ def get(self, page, ext):
self.set_etag_header()
if self.check_etag_header():
self.set_status(304)
return
- if ext == 'tsv':
+ if page == 'fancy':
+ self.fancy_html()
+ elif ext == 'tsv':
self.results_tsv()
elif ext == 'asc':
self.results_asc()
@@ -240,6 +242,34 @@
}
self.render('results.html', **context)
+ def fancy_html(self):
+ changesets = self.getchangesets()
+ marks, moremarks = self.getmarks()
+ results, _ = self.getresults(changesets, marks=marks, colors=False)
+ json = []
+ for cset in changesets:
+ item = {'rev': cset['rev']}
+ for mark in marks:
+ values = results.get(cset['node'], {}).get(mark, None)
+ if values is not None:
+ item[mark] = values[0]
+ json.append(item)
+ data = {
+ 'names': marks,
+ 'x': 'rev',
+ 'json': json,
+ 'keys': {'x': 'rev', 'value': marks.keys()}
+ }
+ context = {
+ 'changesets': changesets,
+ 'marks': marks,
+ 'moremarks': moremarks,
+ 'setrev': self.setrev,
+ 'setmarks': self.setmarks(marks),
+ 'data': data
+ }
+ self.render('fancy.html', **context)
+
def green_to_red((low, high), value):
hue = (value - low) / (high - low) if high != low else 0.5
@@ -251,7 +281,8 @@
def __init__(self):
handlers = [
URLSpec(r'/', IndexHandler),
- URLSpec(r'/results\.(html|tsv|asc)', ResultsHandler),
+ URLSpec(r'/(results)\.(html|tsv|asc)', ResultsHandler),
+ URLSpec(r'/(fancy)\.(html)', ResultsHandler),
]
settings = dict(
template_path=TEMPLATES,