summaryrefslogtreecommitdiff
path: root/android_benchmark_views_app/views.py
blob: 041426e8914d52e5189ccc6f65beb788f651ce6d (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright (C) 2012 Linaro Limited
#
# Author: Andy Doan <andy.doan@linaro.org>
#
# This file is part of LAVA Android Benchmark Views.
#
# LAVA Android Benchmark Views is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License version 3 as
# published by the Free Software Foundation
#
# LAVA Android Benchmark Views is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with LAVA Android Benchmark Views.  If not, see <http://www.gnu.org/licenses/>.

from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext

import dashboard_app.views

from android_benchmark_views_app.models import (
    BenchmarkReport,
    BenchmarkRun,
)

from lava_server.bread_crumbs import (
    BreadCrumb,
    BreadCrumbTrail,
)


@BreadCrumb(
    "Android Benchmarks",
    parent=None
)
def index(request):
    reports = BenchmarkReport.objects.filter(can_publish=True).order_by('series').reverse()
    history_reports = reports
    if reports.count() > 6:
        history_reports = reports[6:]

    # fake out data so that we can compare GCC 4.6 performance
    # over the last 6 months
    report = BenchmarkReport()
    report_index = BenchmarkReport.objects.filter(series='index')
    if report_index.count() == 1:
        report = report_index[0]

    runs = []
    for r in history_reports:
        run = BenchmarkRun()
        run.report = report
        run.label = r.series
        b = BenchmarkRun.objects.filter(report=r, label='linaro-4.6')
        run.bundle = b[0].bundle
        runs.append(run)

    return render_to_response(
        "android_benchmark_views_app/index.html", {
            'report': report,
            'reports': reports,
            'runs': runs,

            'bread_crumb_trail': BreadCrumbTrail.leading_to(index)
        }, RequestContext(request))

@BreadCrumb(
    "{series}",
    parent=index,
    needs = ['series']
)
def report(request, series):
    br   = get_object_or_404(BenchmarkReport, series=series)
    runs = BenchmarkRun.objects.filter(report=br)

    return render_to_response(
        "android_benchmark_views_app/report.html", {
            'report': br,
            'runs': runs,

            'bread_crumb_trail': BreadCrumbTrail.leading_to(
                    report, series=series)
        }, RequestContext(request))

@BreadCrumb(
    "{run} Results",
    parent=report,
    needs=['series', 'run'])
def run_summary(request, series, run):
    report = get_object_or_404(BenchmarkReport, series=series)
    run = get_object_or_404(BenchmarkRun, pk=run)

    test_averages = run.get_test_averages()

    bundle_url = run.bundle.get_permalink()

    return render_to_response(
        "android_benchmark_views_app/run.html", {
            'report': report,
            'run': run,
            'test_averages': test_averages,
            'bundle_url': bundle_url,

            'bread_crumb_trail': BreadCrumbTrail.leading_to(
                    run_summary, series=series, run=run.label)
        }, RequestContext(request))