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

Side by Side Diff: tools/profviz/profviz.js

Issue 17620008: Include statistical profile into profviz. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: small tweak Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 var worker_scripts = [ 28 var worker_scripts = [
29 "../csvparser.js", 29 "../csvparser.js",
30 "../splaytree.js", 30 "../splaytree.js",
31 "../codemap.js", 31 "../codemap.js",
32 "../consarray.js",
32 "../profile.js", 33 "../profile.js",
33 "../profile_view.js", 34 "../profile_view.js",
34 "../logreader.js", 35 "../logreader.js",
35 "../tickprocessor.js", 36 "../tickprocessor.js",
36 "composer.js", 37 "composer.js",
37 "gnuplot-4.6.3-emscripten.js" 38 "gnuplot-4.6.3-emscripten.js"
38 ]; 39 ];
39 40
40 41
41 function plotWorker() { 42 function plotWorker() {
42 var worker = null; 43 var worker = null;
43 44
44 var delegateList = { 45 var delegateList = {
45 "log" : log, 46 "log" : log,
46 "error" : logError, 47 "error" : logError,
47 "display" : display, 48 "displayplot" : displayplot,
48 "range" : setRange, 49 "displayprof" : displayprof,
49 "script" : scriptLoaded 50 "range" : setRange,
51 "script" : scriptLoaded
50 } 52 }
51 53
52 function initialize() { 54 function initialize() {
53 ui.freeze(); 55 ui.freeze();
54 worker = new Worker("worker.js"); 56 worker = new Worker("worker.js");
55 running = false; 57 running = false;
56 58
57 worker.postMessage({ "call" : "load scripts", 59 worker.postMessage({ "call" : "load scripts",
58 "args" : worker_scripts }); 60 "args" : worker_scripts });
59 61
(...skipping 30 matching lines...) Expand all
90 } 92 }
91 93
92 94
93 function UIWrapper() { 95 function UIWrapper() {
94 var input_elements = ["range_start", 96 var input_elements = ["range_start",
95 "range_end", 97 "range_end",
96 "distortion", 98 "distortion",
97 "start", 99 "start",
98 "file"]; 100 "file"];
99 101
100 this.log = document.getElementById("log"); 102 var other_elements = ["log",
101 this.plot = document.getElementById('plot'); 103 "plot",
104 "prof",
105 "instructions",
106 "credits",
107 "toggledisplay"];
108
102 for (var i in input_elements) { 109 for (var i in input_elements) {
103 var id = input_elements[i]; 110 var id = input_elements[i];
104 this[id] = document.getElementById(id); 111 this[id] = document.getElementById(id);
105 } 112 }
106 113
114 for (var i in other_elements) {
115 var id = other_elements[i];
116 this[id] = document.getElementById(id);
117 }
118
107 this.freeze = function() { 119 this.freeze = function() {
108 this.plot.style.webkitFilter = "grayscale(1)"; 120 this.plot.style.webkitFilter = "grayscale(1)";
121 this.prof.style.color = "#bbb";
109 for (var i in input_elements) { 122 for (var i in input_elements) {
110 this[input_elements[i]].disabled = true; 123 this[input_elements[i]].disabled = true;
111 } 124 }
112 } 125 }
113 126
114 this.thaw = function() { 127 this.thaw = function() {
115 this.plot.style.webkitFilter = ""; 128 this.plot.style.webkitFilter = "";
129 this.prof.style.color = "#000";
116 for (var i in input_elements) { 130 for (var i in input_elements) {
117 this[input_elements[i]].disabled = false; 131 this[input_elements[i]].disabled = false;
118 } 132 }
119 } 133 }
120 134
121 this.reset = function() { 135 this.reset = function() {
122 this.thaw(); 136 this.thaw();
123 this.log.value = ""; 137 this.log.value = "";
124 this.range_start.value = "automatic"; 138 this.range_start.value = "automatic";
125 this.range_end.value = "automatic"; 139 this.range_end.value = "automatic";
140 this.toggle("plot");
141 this.plot.src = "";
142 this.prof.value = "";
143 }
144
145 this.toggle = function(mode) {
146 if (mode) this.toggledisplay.next_mode = mode;
147 if (this.toggledisplay.next_mode == "plot") {
148 this.toggledisplay.next_mode = "prof";
149 this.plot.style.display = "block";
150 this.prof.style.display = "none";
151 this.toggledisplay.innerHTML = "Show profile";
152 } else {
153 this.toggledisplay.next_mode = "plot";
154 this.plot.style.display = "none";
155 this.prof.style.display = "block";
156 this.toggledisplay.innerHTML = "Show plot";
157 }
158 }
159
160 this.info = function(field) {
161 var down_arrow = "\u25bc";
162 var right_arrow = "\u25b6";
163 if (field && this[field].style.display != "none") field = null; // Toggle.
164 this.credits.style.display = "none";
165 this.instructions.style.display = "none";
166 if (!field) return;
167 this[field].style.display = "block";
126 } 168 }
127 } 169 }
128 170
129 171
130 function log(text) { 172 function log(text) {
131 ui.log.value += text; 173 ui.log.value += text;
132 ui.log.scrollTop = ui.log.scrollHeight; 174 ui.log.scrollTop = ui.log.scrollHeight;
133 } 175 }
134 176
135 177
136 function logError(text) { 178 function logError(text) {
137 if (ui.log.value.length > 0 && 179 if (ui.log.value.length > 0 &&
138 ui.log.value[ui.log.value.length-1] != "\n") { 180 ui.log.value[ui.log.value.length-1] != "\n") {
139 ui.log.value += "\n"; 181 ui.log.value += "\n";
140 } 182 }
141 ui.log.value += "ERROR: " + text + "\n"; 183 ui.log.value += "ERROR: " + text + "\n";
142 ui.log.scrollTop = ui.log.scrollHeight; 184 ui.log.scrollTop = ui.log.scrollHeight;
143 error_logged = true; 185 error_logged = true;
144 } 186 }
145 187
146 188
147 function display(args) { 189 function displayplot(args) {
148 if (error_logged) { 190 if (error_logged) {
149 log("Plot failed.\n\n"); 191 log("Plot failed.\n\n");
150 } else { 192 } else {
151 log("Displaying plot. Total time: " + 193 log("Displaying plot. Total time: " +
152 (Date.now() - timer) / 1000 + "ms.\n\n"); 194 (Date.now() - timer) / 1000 + "ms.\n\n");
153 var blob = new Blob([new Uint8Array(args.contents).buffer], 195 var blob = new Blob([new Uint8Array(args.contents).buffer],
154 { "type" : "image\/svg+xml" }); 196 { "type" : "image\/svg+xml" });
155 window.URL = window.URL || window.webkitURL; 197 window.URL = window.URL || window.webkitURL;
156 ui.plot.src = window.URL.createObjectURL(blob); 198 ui.plot.src = window.URL.createObjectURL(blob);
157 } 199 }
158 200
159 ui.thaw(); 201 ui.thaw();
202 ui.toggle("plot");
160 } 203 }
161 204
162 205
206 function displayprof(args) {
207 if (error_logged) return;
208 ui.prof.value = args;
209 this.prof.style.color = "";
210 ui.toggle("prof");
211 }
212
213
163 function start(event) { 214 function start(event) {
164 error_logged = false; 215 error_logged = false;
165 ui.freeze(); 216 ui.freeze();
166 217
167 try { 218 try {
168 var file = getSelectedFile(); 219 var file = getSelectedFile();
169 var distortion = getDistortion(); 220 var distortion = getDistortion();
170 var range = getRange(); 221 var range = getRange();
171 } catch (e) { 222 } catch (e) {
172 logError(e.message); 223 logError(e.message);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 261 }
211 262
212 263
213 function setRange(args) { 264 function setRange(args) {
214 ui.range_start.value = args.start.toFixed(1); 265 ui.range_start.value = args.start.toFixed(1);
215 ui.range_end.value = args.end.toFixed(1); 266 ui.range_end.value = args.end.toFixed(1);
216 } 267 }
217 268
218 269
219 function onload() { 270 function onload() {
220 kResX = 1600; 271 kResX = 1200;
221 kResY = 900; 272 kResY = 600;
222 error_logged = false; 273 error_logged = false;
223 ui = new UIWrapper(); 274 ui = new UIWrapper();
224 ui.reset(); 275 ui.reset();
276 ui.info(null);
225 worker = new plotWorker(); 277 worker = new plotWorker();
226 worker.reset(); 278 worker.reset();
227 } 279 }
228 280
229 281
230 var kResX; 282 var kResX;
231 var kResY; 283 var kResY;
232 var error_logged; 284 var error_logged;
233 var ui; 285 var ui;
234 var worker; 286 var worker;
235 var timer; 287 var timer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698