1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/build/android/pylib/device_stats_monitor.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,143 @@ 1.4 +<!DOCTYPE html> 1.5 +<!-- 1.6 + * Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this 1.7 + * source code is governed by a BSD-style license that can be found in the 1.8 + * LICENSE file. 1.9 +--> 1.10 +<html> 1.11 +<head> 1.12 + <title>Device Stats Monitor</title> 1.13 + <script type="text/javascript" src="http://www.google.com/jsapi"></script> 1.14 + <style> 1.15 + body { 1.16 + font-family: sans-serif 1.17 + } 1.18 + </style> 1.19 +</head> 1.20 +<body> 1.21 +<h2>Device Stats Monitor</h2> 1.22 +<ul> 1.23 +<li>Pass path to trace data via the <code>results</code> querystring param. 1.24 +<li>Combine charts with the <code>combine</code> querystring param (e.g. <code>&combine=sectors_read,sectors_written</code>). 1.25 +<li>Use <code>stacked=true</code> to stack combined charts instead of overlaying (default). 1.26 +</ul> 1.27 +</body> 1.28 +<script> 1.29 +google.load("visualization", "1", {packages:["corechart"]}); 1.30 + 1.31 +/** 1.32 + * @returns The querystring param value for |name| or an empty string. 1.33 + */ 1.34 +function getQuerystringParam(name) { 1.35 + name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 1.36 + var regexS = "[\\?&]" + name + "=([^&#]*)"; 1.37 + var regex = new RegExp(regexS); 1.38 + var results = regex.exec(window.location.search); 1.39 + if (results == null) 1.40 + return ""; 1.41 + else 1.42 + return decodeURIComponent(results[1].replace(/\+/g, " ")); 1.43 +} 1.44 + 1.45 +/** 1.46 + * @returns An array of keys in |obj| sorted by value. 1.47 + */ 1.48 +function sortedKeys(obj) { 1.49 + var keys = []; 1.50 + for (var key in obj) { 1.51 + keys.push(key); 1.52 + } 1.53 + keys.sort(); 1.54 + return keys; 1.55 +} 1.56 + 1.57 +/** 1.58 + * Removes by value all params from array. 1.59 + */ 1.60 +Array.prototype.remove = function() { 1.61 + var what, a = arguments, l = a.length, ax; 1.62 + while (l && this.length) { 1.63 + what = a[--l]; 1.64 + while ((ax = this.indexOf(what)) != -1) { 1.65 + this.splice(ax, 1); 1.66 + } 1.67 + } 1.68 + return this; 1.69 +} 1.70 + 1.71 +/** 1.72 + * Displays a new chart. 1.73 + * 1.74 + * @param {Number} hz Number of sample per second of the data. 1.75 + * @param {String} name Name to display on top of chart. 1.76 + * @param {Number[][]} values Array of value arrays to display. 1.77 + * @param {Boolean} stacked Whether to display values as stacked. 1.78 + */ 1.79 +function displayChart(hz, name, values, units, stacked) { 1.80 + var data = new google.visualization.DataTable(); 1.81 + data.addColumn('number', 'ms'); 1.82 + var names = name.split(','); 1.83 + for (var i = 0; i < names.length; i++) { 1.84 + data.addColumn('number', names[i]); 1.85 + } 1.86 + 1.87 + var rows = []; 1.88 + var interval = 1000.0 / hz; 1.89 + for (var i = 0; i < values[0].length; i++) { 1.90 + var row = [i*interval]; 1.91 + for (var j = 0; j < values.length; j++) { 1.92 + row.push(values[j][i]); 1.93 + } 1.94 + rows.push(row); 1.95 + } 1.96 + data.addRows(rows); 1.97 + 1.98 + var options = { 1.99 + hAxis: {title: 'ms (' + hz + 'hz)'}, 1.100 + isStacked: stacked, 1.101 + legend: {position: 'top'}, 1.102 + vAxis: {title: units}, 1.103 + }; 1.104 + 1.105 + var elem = document.createElement('DIV'); 1.106 + elem.style = 'width:100%;height:500px'; 1.107 + document.body.appendChild(elem); 1.108 + var chart = new google.visualization.AreaChart(elem); 1.109 + chart.draw(data, options); 1.110 +} 1.111 + 1.112 +/** 1.113 + * Displays all charts. 1.114 + * 1.115 + * Invoked by the results script. JSONP is used to avoid security 1.116 + * restrictions on XHRs for file:// URLs. 1.117 + */ 1.118 +function display(hz, results, units) { 1.119 + var combine = getQuerystringParam('combine'); 1.120 + var keys = sortedKeys(results); 1.121 + for (var i = 0; i < keys.length; i++) { 1.122 + var key = keys[i]; 1.123 + var name = key; 1.124 + var values = [results[key]]; 1.125 + var unit = units[key]; 1.126 + if (combine.indexOf(key) >= 0) { 1.127 + i--; 1.128 + name = combine; 1.129 + values = []; 1.130 + var combined_keys = combine.split(','); 1.131 + for (var j = 0; j < combined_keys.length; j++) { 1.132 + values.push(results[combined_keys[j]]); 1.133 + keys.remove(combined_keys[j]); 1.134 + } 1.135 + } 1.136 + displayChart(hz, name, values, unit, !!getQuerystringParam('stacked')); 1.137 + } 1.138 +} 1.139 + 1.140 +var resultsPath = getQuerystringParam('results'); 1.141 +if (resultsPath) 1.142 + document.write("<script src='" + resultsPath + "'></"+"script>"); 1.143 +else 1.144 + document.write("Please specify results querystring param."); 1.145 +</script> 1.146 +</html>