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

Side by Side Diff: webrtc/tools/rtcbot/rtcBotReportVisualizer/main.js

Issue 2965593002: Move webrtc/{tools => rtc_tools} (Closed)
Patch Set: Adding back root changes Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « webrtc/tools/rtcbot/rtcBotReportVisualizer/index.html ('k') | webrtc/tools/rtcbot/test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 //
9 google.load("visualization", "1", {packages:["corechart"]});
10
11 function openFiles(event) {
12 var files = event.target.files;
13 readAndAnalyzeFiles(files)
14 }
15
16 function readAndAnalyzeFiles(files) {
17 if(!files) {
18 alert("No files have been selected!");
19 return;
20 }
21
22 var reports = [];
23 var filesNames = [];
24 missingFiles = files.length;
25
26 for(var i = 0; i < files.length; i++) {
27 var reader = new FileReader();
28 reader.onload = onReaderLoad.bind(reader, files[i].name);
29 reader.readAsText(files[i]);
30 }
31
32 function onReaderLoad(fileName) {
33 reports.push(JSON.parse(this.result));
34 filesNames.push(fileName);
35
36 missingFiles--;
37 if(missingFiles == 0) {
38 analyzeReports_(reports, filesNames);
39 }
40 }
41 }
42
43 // TODO(houssainy) take the input stats from the select list or
44 // drop down menu in html.
45 function analyzeReports_(reports, filesNames) {
46 filesNames.unshift(""); // ned
47
48 // Rtt
49 analyzeRttData(reports, filesNames, "bot1");
50 analyzeRttData(reports, filesNames, "bot2");
51
52 // Send Packets Lost
53 analyzePacketsLostData(reports, filesNames, "bot1");
54 analyzePacketsLostData(reports, filesNames, "bot2");
55
56 // Send bandwidth
57 analyzeData(reports, filesNames, "Available Send Bandwidth-bot1", "bot1",
58 "bweforvideo", "googAvailableSendBandwidth");
59 analyzeData(reports, filesNames, "Available Send Bandwidth-bot2", "bot2",
60 "bweforvideo", "googAvailableSendBandwidth");
61
62 // Receive bandwidth
63 analyzeData(reports, filesNames, "Available Receive Bandwidth-bot1", "bot1",
64 "bweforvideo", "googAvailableReceiveBandwidth");
65 analyzeData(reports, filesNames, "Available Receive Bandwidth-bot2", "bot2",
66 "bweforvideo", "googAvailableReceiveBandwidth");
67
68 drawSeparatorLine();
69 }
70
71 function analyzeRttData(reports, filesNames, botName) {
72 var outPut = [];
73 outPut.push(filesNames);
74
75 var avergaData = ['Average Rtt x10'];
76 var maxData = ['Max Rtt'];
77
78 var average;
79 var max;
80 for(var index in reports) {
81 average = getStateAverage(reports[index], botName, "Conn-audio-1-0",
82 "googRtt");
83 avergaData.push(average*10);
84
85 max = getStateMax(reports[index], botName, "Conn-audio-1-0",
86 "googRtt");
87 maxData.push(max);
88 }
89 outPut.push(avergaData);
90 outPut.push(maxData);
91
92 drawChart("Rtt-" + botName, outPut);
93 }
94
95 function analyzePacketsLostData(reports, filesNames, botName) {
96 var outPut = [];
97 outPut.push(filesNames);
98
99 var maxData = ['Max Send PacketsLost'];
100 var max;
101 for(var index in reports) {
102 max = getStateMax(reports[index], botName, "ssrc_[0-9]+_send",
103 "packetsLost");
104 maxData.push(max);
105 }
106 outPut.push(maxData);
107
108 drawChart("Send PacketsLost-" + botName, outPut);
109 }
110
111 function analyzeData(reports, filesNames, chartName, botName, reportId,
112 statName) {
113 var outPut = [];
114 outPut.push(filesNames);
115
116 var avergaData = ['Average ' + statName];
117 var maxData = ['Max ' + statName];
118
119 var average;
120 var max;
121 for(var index in reports) {
122 average = getStateAverage(reports[index], botName, reportId, statName);
123 avergaData.push(average);
124
125 max = getStateMax(reports[index], botName, reportId, statName);
126 maxData.push(max);
127 }
128 outPut.push(avergaData);
129 outPut.push(maxData);
130
131 drawChart(chartName, outPut);
132 }
133
134 function getStateAverage(reports, botName, reportId, statName) {
135 var sum = 0;
136 var count = 0;
137
138 for (var index in reports) {
139 var data = reports[index].data;
140 if(index == 0 || !data.hasOwnProperty(botName))
141 continue;
142
143 var stats = data[botName];
144 for (var key in stats) {
145 if(key.search(reportId) != -1) {
146 var value = parseInt(stats[key][statName]);
147 sum += value;
148 count++;
149 }
150 }
151 }
152 return Math.round(sum/count);
153 }
154
155 function getStateMax(reports, botName, reportId, statName) {
156 var max = -1;
157
158 for (var index in reports) {
159 var data = reports[index].data;
160 if(index == 0 || !data.hasOwnProperty(botName))
161 continue;
162
163 var stats = data[botName];
164 for (var key in stats) {
165 if(key.search(reportId) != -1) {
166 var value = parseInt(stats[key][statName]);
167 max = Math.max(value, max);
168 }
169 }
170 }
171 return max;
172 }
173
174 function drawChart(title, data) {
175 var dataTable = google.visualization.arrayToDataTable(data);
176
177 var options = {
178 title: title,
179 };
180
181 var div = document.createElement('div');
182 document.body.appendChild(div);
183
184 var chart = new google.visualization.ColumnChart(div);
185 chart.draw(dataTable, options);
186 }
187
188 function drawSeparatorLine() {
189 var hr = document.createElement('hr');
190 document.body.appendChild(hr);
191 }
OLDNEW
« no previous file with comments | « webrtc/tools/rtcbot/rtcBotReportVisualizer/index.html ('k') | webrtc/tools/rtcbot/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698