Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Unified Diff: frontend/croschart/views.py

Issue 6821082: Integrate dynamic charts into autotest frontend. (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: Make multi-chart pages look like current pages. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: frontend/croschart/views.py
diff --git a/frontend/croschart/views.py b/frontend/croschart/views.py
new file mode 100644
index 0000000000000000000000000000000000000000..b1c1ab5d904e5a53da474895feee23efb1ce94fb
--- /dev/null
+++ b/frontend/croschart/views.py
@@ -0,0 +1,137 @@
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import os
+
+import django.http
+from django.shortcuts import render_to_response
+
+from autotest_lib.frontend.croschart import models
+from autotest_lib.frontend.croschart.gviz_python import gviz_api
+
+
+class ChartException(Exception):
+ pass
+
+
+def CommonPlotChart(boards, netbook, from_build, to_build,
+ test_name, test_key, width, height):
+ try:
+ tpl_gviz_id = '%s-%s' % (test_name, test_key)
+ tpl_gviz_title = test_name
+ tpl_perf_key = test_key
+ tpl_width = width
+ tpl_height = height
+ gviz_data, tpl_job_tags = models.GetChartData(
+ boards, netbook, from_build, to_build, test_name, test_key)
+ if not gviz_data:
+ raise ChartException
+ # Use gviz_api to create efficient data tables.
+ data_table = gviz_api.DataTable({
+ 'build': ('string', 'Build'),
+ tpl_perf_key: ('number', tpl_perf_key)})
+ data_table.LoadData(gviz_data)
+ tpl_gviz_js = data_table.ToJSon(['build', tpl_perf_key])
+ tpl_colors = ['red', 'blue', 'green', 'black']
+ return render_to_response('plot_chart.html', locals())
+ except:
+ return render_to_response('plot_unavailable.html', locals())
+
+
+# Responds to restful request.
+def PlotChartFromBuilds(request, boards, netbook, from_build, to_build,
+ test_name, test_key, width, height):
+ return CommonPlotChart(boards, netbook, from_build, to_build,
+ test_name, test_key, width, height)
+
+
+def PlotChart(request, boards, netbook, test_name, test_key, width, height):
+ from_build = to_build = None
+ return CommonPlotChart(boards, netbook, from_build, to_build,
+ test_name, test_key, width, height)
+
+
+def CommonFrameCharts(tpl_boards, tpl_netbook, tpl_width, tpl_height):
+ tpl_charts = [
+ ('platform_BootPerfServer', 'seconds_kernel_to_startup'),
ericli 2011/04/13 22:07:47 I would refactor it out to some config file, so 1
truty 2011/04/14 19:01:51 I actually spent a fair amount of time trying to g
+ ('platform_BootPerfServer', 'seconds_kernel_to_startup_done'),
+ ('platform_BootPerfServer', 'seconds_kernel_to_x_started'),
+ ('platform_BootPerfServer', 'seconds_kernel_to_chrome_exec'),
+ ('platform_BootPerfServer', 'seconds_kernel_to_chrome_main'),
+ ('platform_BootPerfServer', 'seconds_kernel_to_login'),
+ ('platform_BootPerfServer', 'seconds_kernel_to_network'),
+ ('platform_BootPerfServer', 'seconds_power_on_to_login'),
+ ('platform_BootPerfServer', 'seconds_reboot_time'),
+ ('platform_BootPerfServer', 'seconds_shutdown_time'),
+ ('platform_BootPerfServer', 'rdbytes_kernel_to_startup'),
+ ('platform_BootPerfServer', 'rdbytes_kernel_to_startup_done'),
+ ('platform_BootPerfServer', 'rdbytes_kernel_to_x_started'),
+ ('platform_BootPerfServer', 'rdbytes_kernel_to_chrome_exec'),
+ ('platform_BootPerfServer', 'rdbytes_kernel_to_chrome_main'),
+ ('platform_BootPerfServer', 'rdbytes_kernel_to_login'),
+ ('platform_BootPerfServer', 'seconds_firmware_boot'),
+ ('desktopui_ChromeFirstRender', 'seconds_chrome_first_tab'),
+ ('build_RootFilesystemSize', 'bytes_rootfs_prod'),
+ ('build_RootFilesystemSize', 'bytes_rootfs_test'),
+ ('power_LoadTest.WIFI', 'w_energy_rate'),
+ ('power_LoadTest.WIFI', 'minutes_battery_life'),
+ ('power_LoadTest.WIRED', 'w_energy_rate'),
+ ('power_LoadTest.WIRED', 'minutes_battery_life'),
+ ('power_Idle', 'w_energy_rate'),
+ ('power_Resume', 'seconds_system_resume'),
+ ('power_Resume', 'seconds_system_suspend'),
+ ('power_Resume', 'seconds_system_resume_firmware'),
+ ('power_Resume', 'seconds_system_resume_kernel'),
+ ('hardware_MemoryThroughput', 'mb_per_sec_memory_cp_256k_seq'),
+ ('hardware_MemoryThroughput', 'mb_per_sec_memory_r_256k_ran'),
+ ('hardware_MemoryThroughput', 'mb_per_sec_memory_rw_256k_seq'),
+ ('hardware_MemoryThroughput', 'mb_per_sec_memory_set_256k_seq'),
+ ('hardware_MemoryThroughput', 'mb_per_sec_memory_w_256k_seq'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.Alexa_usFile'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.MozFile'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.Moz2File'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.DhtmlFile'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.Intl1File'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.Intl2File'),
+ ('desktopui_PageCyclerTests', 'PageCyclerTest.BloatFile'),
+ ('desktopui_V8Bench', 'score_crypto'),
+ ('desktopui_V8Bench', 'score_deltablue'),
+ ('desktopui_V8Bench', 'score_earleyboyer'),
+ ('desktopui_V8Bench', 'score_raytrace'),
+ ('desktopui_V8Bench', 'score_regexp'),
+ ('desktopui_V8Bench', 'score_richards'),
+ ('desktopui_V8Bench', 'score_splay'),
+ ('desktopui_V8Bench', 'score_total')]
+ return render_to_response('charts.html', locals())
+
+
+def FrameCharts(request):
+ boards = 'x86-mario-r12'
ericli 2011/04/13 22:07:47 sounds like boards = ['x86-mario-r12'] is more app
truty 2011/04/14 19:01:51 Removed. This was for demos.
+ netbook = 'MARIO_MP'
+ width = 320
+ height = 240
+ return CommonFrameCharts(boards, netbook, width, height)
+
+
+def FrameChartsBoardNetbook(request, boards, netbook, width, height):
+ return CommonFrameCharts(boards, netbook, width, height)
+
+
+def FrameChartsTestsKeys(request, boards, netbook, from_build, to_build,
+ test_key_names, width, height):
+ tpl_width = width
+ tpl_height = height
+ tpl_boards = boards
+ tpl_netbook = netbook
+ tpl_from_build = from_build
+ tpl_to_build = to_build
+ tpl_charts = [c.split(',') for c in test_key_names.split('&')]
+ return render_to_response('charts.html', locals())
+
+
+# Populate a chart landing page.
+def ChartChoices(request):
+ # Get some builds, tests and keys.
+ # It'd be really nice to map keys to tests.
+ return django.http.HttpResponse(
+ 'In ChartChoices UI <tbd>.')

Powered by Google App Engine
This is Rietveld 408576698