OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 import os | |
5 | |
6 import django.http | |
7 from django.shortcuts import render_to_response | |
8 | |
9 from autotest_lib.frontend.croschart import models | |
10 from autotest_lib.frontend.croschart.gviz_python import gviz_api | |
11 | |
12 | |
13 class ChartException(Exception): | |
14 pass | |
15 | |
16 | |
17 def CommonPlotChart(boards, netbook, from_build, to_build, | |
18 test_name, test_key, width, height): | |
19 try: | |
20 tpl_gviz_id = '%s-%s' % (test_name, test_key) | |
21 tpl_gviz_title = test_name | |
22 tpl_perf_key = test_key | |
23 tpl_width = width | |
24 tpl_height = height | |
25 gviz_data, tpl_job_tags = models.GetChartData( | |
26 boards, netbook, from_build, to_build, test_name, test_key) | |
27 if not gviz_data: | |
28 raise ChartException | |
29 # Use gviz_api to create efficient data tables. | |
30 data_table = gviz_api.DataTable({ | |
31 'build': ('string', 'Build'), | |
32 tpl_perf_key: ('number', tpl_perf_key)}) | |
33 data_table.LoadData(gviz_data) | |
34 tpl_gviz_js = data_table.ToJSon(['build', tpl_perf_key]) | |
35 tpl_colors = ['red', 'blue', 'green', 'black'] | |
36 return render_to_response('plot_chart.html', locals()) | |
37 except: | |
38 return render_to_response('plot_unavailable.html', locals()) | |
39 | |
40 | |
41 # Responds to restful request. | |
42 def PlotChartFromBuilds(request, boards, netbook, from_build, to_build, | |
43 test_name, test_key, width, height): | |
44 return CommonPlotChart(boards, netbook, from_build, to_build, | |
45 test_name, test_key, width, height) | |
46 | |
47 | |
48 def PlotChart(request, boards, netbook, test_name, test_key, width, height): | |
49 from_build = to_build = None | |
50 return CommonPlotChart(boards, netbook, from_build, to_build, | |
51 test_name, test_key, width, height) | |
52 | |
53 | |
54 def CommonFrameCharts(tpl_boards, tpl_netbook, tpl_width, tpl_height): | |
55 tpl_charts = [ | |
56 ('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
| |
57 ('platform_BootPerfServer', 'seconds_kernel_to_startup_done'), | |
58 ('platform_BootPerfServer', 'seconds_kernel_to_x_started'), | |
59 ('platform_BootPerfServer', 'seconds_kernel_to_chrome_exec'), | |
60 ('platform_BootPerfServer', 'seconds_kernel_to_chrome_main'), | |
61 ('platform_BootPerfServer', 'seconds_kernel_to_login'), | |
62 ('platform_BootPerfServer', 'seconds_kernel_to_network'), | |
63 ('platform_BootPerfServer', 'seconds_power_on_to_login'), | |
64 ('platform_BootPerfServer', 'seconds_reboot_time'), | |
65 ('platform_BootPerfServer', 'seconds_shutdown_time'), | |
66 ('platform_BootPerfServer', 'rdbytes_kernel_to_startup'), | |
67 ('platform_BootPerfServer', 'rdbytes_kernel_to_startup_done'), | |
68 ('platform_BootPerfServer', 'rdbytes_kernel_to_x_started'), | |
69 ('platform_BootPerfServer', 'rdbytes_kernel_to_chrome_exec'), | |
70 ('platform_BootPerfServer', 'rdbytes_kernel_to_chrome_main'), | |
71 ('platform_BootPerfServer', 'rdbytes_kernel_to_login'), | |
72 ('platform_BootPerfServer', 'seconds_firmware_boot'), | |
73 ('desktopui_ChromeFirstRender', 'seconds_chrome_first_tab'), | |
74 ('build_RootFilesystemSize', 'bytes_rootfs_prod'), | |
75 ('build_RootFilesystemSize', 'bytes_rootfs_test'), | |
76 ('power_LoadTest.WIFI', 'w_energy_rate'), | |
77 ('power_LoadTest.WIFI', 'minutes_battery_life'), | |
78 ('power_LoadTest.WIRED', 'w_energy_rate'), | |
79 ('power_LoadTest.WIRED', 'minutes_battery_life'), | |
80 ('power_Idle', 'w_energy_rate'), | |
81 ('power_Resume', 'seconds_system_resume'), | |
82 ('power_Resume', 'seconds_system_suspend'), | |
83 ('power_Resume', 'seconds_system_resume_firmware'), | |
84 ('power_Resume', 'seconds_system_resume_kernel'), | |
85 ('hardware_MemoryThroughput', 'mb_per_sec_memory_cp_256k_seq'), | |
86 ('hardware_MemoryThroughput', 'mb_per_sec_memory_r_256k_ran'), | |
87 ('hardware_MemoryThroughput', 'mb_per_sec_memory_rw_256k_seq'), | |
88 ('hardware_MemoryThroughput', 'mb_per_sec_memory_set_256k_seq'), | |
89 ('hardware_MemoryThroughput', 'mb_per_sec_memory_w_256k_seq'), | |
90 ('desktopui_PageCyclerTests', 'PageCyclerTest.Alexa_usFile'), | |
91 ('desktopui_PageCyclerTests', 'PageCyclerTest.MozFile'), | |
92 ('desktopui_PageCyclerTests', 'PageCyclerTest.Moz2File'), | |
93 ('desktopui_PageCyclerTests', 'PageCyclerTest.DhtmlFile'), | |
94 ('desktopui_PageCyclerTests', 'PageCyclerTest.Intl1File'), | |
95 ('desktopui_PageCyclerTests', 'PageCyclerTest.Intl2File'), | |
96 ('desktopui_PageCyclerTests', 'PageCyclerTest.BloatFile'), | |
97 ('desktopui_V8Bench', 'score_crypto'), | |
98 ('desktopui_V8Bench', 'score_deltablue'), | |
99 ('desktopui_V8Bench', 'score_earleyboyer'), | |
100 ('desktopui_V8Bench', 'score_raytrace'), | |
101 ('desktopui_V8Bench', 'score_regexp'), | |
102 ('desktopui_V8Bench', 'score_richards'), | |
103 ('desktopui_V8Bench', 'score_splay'), | |
104 ('desktopui_V8Bench', 'score_total')] | |
105 return render_to_response('charts.html', locals()) | |
106 | |
107 | |
108 def FrameCharts(request): | |
109 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.
| |
110 netbook = 'MARIO_MP' | |
111 width = 320 | |
112 height = 240 | |
113 return CommonFrameCharts(boards, netbook, width, height) | |
114 | |
115 | |
116 def FrameChartsBoardNetbook(request, boards, netbook, width, height): | |
117 return CommonFrameCharts(boards, netbook, width, height) | |
118 | |
119 | |
120 def FrameChartsTestsKeys(request, boards, netbook, from_build, to_build, | |
121 test_key_names, width, height): | |
122 tpl_width = width | |
123 tpl_height = height | |
124 tpl_boards = boards | |
125 tpl_netbook = netbook | |
126 tpl_from_build = from_build | |
127 tpl_to_build = to_build | |
128 tpl_charts = [c.split(',') for c in test_key_names.split('&')] | |
129 return render_to_response('charts.html', locals()) | |
130 | |
131 | |
132 # Populate a chart landing page. | |
133 def ChartChoices(request): | |
134 # Get some builds, tests and keys. | |
135 # It'd be really nice to map keys to tests. | |
136 return django.http.HttpResponse( | |
137 'In ChartChoices UI <tbd>.') | |
OLD | NEW |