| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 var call = delegateList[event.data["call"]]; | 34 var call = delegateList[event.data["call"]]; |
| 35 var result = call(event.data["args"]); | 35 var result = call(event.data["args"]); |
| 36 }, false); | 36 }, false); |
| 37 | 37 |
| 38 | 38 |
| 39 function log(text) { | 39 function log(text) { |
| 40 self.postMessage({ "call" : "log", "args" : text }); | 40 self.postMessage({ "call" : "log", "args" : text }); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 function display(content) { | 44 function displayplot(content) { |
| 45 self.postMessage({ "call" : "display", "args" : content}); | 45 self.postMessage({ "call" : "displayplot", "args" : content}); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 function displayprof(content) { |
| 50 self.postMessage({ "call" : "displayprof", "args" : content}); |
| 51 } |
| 52 |
| 53 |
| 49 function setRange(start, end) { | 54 function setRange(start, end) { |
| 50 self.postMessage({ "call" : "range", | 55 self.postMessage({ "call" : "range", |
| 51 "args" : { "start" : start, "end" : end } }); | 56 "args" : { "start" : start, "end" : end } }); |
| 52 } | 57 } |
| 53 | 58 |
| 54 | 59 |
| 55 function time(name, fun) { | 60 function time(name, fun) { |
| 56 log(name + "..."); | 61 log(name + "..."); |
| 57 var start = Date.now(); | 62 var start = Date.now(); |
| 58 fun(); | 63 fun(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 | 82 |
| 78 var reader = new FileReaderSync(); | 83 var reader = new FileReaderSync(); |
| 79 var content_lines; | 84 var content_lines; |
| 80 | 85 |
| 81 time("Reading log file (" + (file.size / 1024).toFixed(1) + " kB)", | 86 time("Reading log file (" + (file.size / 1024).toFixed(1) + " kB)", |
| 82 function() { | 87 function() { |
| 83 var content = reader.readAsText(file); | 88 var content = reader.readAsText(file); |
| 84 content_lines = content.split("\n"); | 89 content_lines = content.split("\n"); |
| 85 }); | 90 }); |
| 86 | 91 |
| 92 time("Producing statistical profile", |
| 93 function() { |
| 94 var profile = ""; |
| 95 print = function(text) { profile += text + "\n"; }; |
| 96 // Dummy entries provider, as we cannot call nm. |
| 97 var entriesProvider = new UnixCppEntriesProvider("", ""); |
| 98 var targetRootFS = ""; |
| 99 var separateIc = false; |
| 100 var callGraphSize = 5; |
| 101 var ignoreUnknown = true; |
| 102 var stateFilter = null; |
| 103 var snapshotLogProcessor = null; |
| 104 var range = range_start_override + "," + range_end_override; |
| 105 |
| 106 var tickProcessor = new TickProcessor(entriesProvider, |
| 107 separateIc, |
| 108 callGraphSize, |
| 109 ignoreUnknown, |
| 110 stateFilter, |
| 111 snapshotLogProcessor, |
| 112 distortion, |
| 113 range); |
| 114 for (var i = 0; i < content_lines.length; i++) { |
| 115 tickProcessor.processLogLine(content_lines[i]); |
| 116 } |
| 117 tickProcessor.printStatistics(); |
| 118 displayprof(profile); |
| 119 }); |
| 120 |
| 87 var input_file_name = "input_temp"; | 121 var input_file_name = "input_temp"; |
| 88 var output_file_name = "output.svg"; | 122 var output_file_name = "output.svg"; |
| 89 | 123 |
| 90 var psc = new PlotScriptComposer(resx, resy); | 124 var psc = new PlotScriptComposer(resx, resy); |
| 91 var objects = 0; | 125 var objects = 0; |
| 92 | 126 |
| 93 time("Analyzing data (" + content_lines.length + " entries)", | 127 time("Collecting events (" + content_lines.length + " entries)", |
| 94 function() { | 128 function() { |
| 95 var line_cursor = 0; | 129 var line_cursor = 0; |
| 96 var input = function() { return content_lines[line_cursor++]; }; | 130 var input = function() { return content_lines[line_cursor++]; }; |
| 97 psc.collectData(input, distortion); | 131 psc.collectData(input, distortion); |
| 98 psc.findPlotRange(range_start_override, | 132 psc.findPlotRange(range_start_override, |
| 99 range_end_override, | 133 range_end_override, |
| 100 setRange); | 134 setRange); |
| 101 }); | 135 }); |
| 102 | 136 |
| 103 time("Assembling plot script", | 137 time("Assembling plot script", |
| 104 function() { | 138 function() { |
| 105 var plot_script = ""; | 139 var plot_script = ""; |
| 106 var output = function(output) { plot_script += output + "\n"; }; | 140 var output = function(text) { plot_script += text + "\n"; }; |
| 107 output("set terminal svg size " + resx + "," + resy + | 141 output("set terminal svg size " + resx + "," + resy + |
| 108 " enhanced font \"Helvetica,10\""); | 142 " enhanced font \"Helvetica,10\""); |
| 109 output("set output \""+ output_file_name + "\""); | 143 output("set output \""+ output_file_name + "\""); |
| 110 objects = psc.assembleOutput(output); | 144 objects = psc.assembleOutput(output); |
| 111 if (FS.findObject(input_file_name)) { | 145 if (FS.findObject(input_file_name)) { |
| 112 FS.deleteFile(input_file_name); | 146 FS.deleteFile(input_file_name); |
| 113 } | 147 } |
| 114 var arrc = Module["intArrayFromString"](plot_script, true); | 148 var arrc = Module["intArrayFromString"](plot_script, true); |
| 115 FS.createDataFile("/", input_file_name, arrc); | 149 FS.createDataFile("/", input_file_name, arrc); |
| 116 }); | 150 }); |
| 117 | 151 |
| 118 time("Running Gnuplot (" + objects + " objects)", | 152 time("Running gnuplot (" + objects + " objects)", |
| 119 function() { Module.run([input_file_name]); }); | 153 function() { Module.run([input_file_name]); }); |
| 120 | 154 |
| 121 display(FS.findObject(output_file_name)); | 155 displayplot(FS.findObject(output_file_name)); |
| 122 } | 156 } |
| 123 | 157 |
| 124 | 158 |
| 125 var Module = { | 159 var Module = { |
| 126 "noInitialRun": true, | 160 "noInitialRun": true, |
| 127 print: function(text) { | 161 print: function(text) { |
| 128 self.postMessage({"call": "error", "args": text}); | 162 self.postMessage({"call": "error", "args": text}); |
| 129 }, | 163 }, |
| 130 printErr: function(text) { | 164 printErr: function(text) { |
| 131 self.postMessage({"call": "error", "args": text}); | 165 self.postMessage({"call": "error", "args": text}); |
| 132 }, | 166 }, |
| 133 }; | 167 }; |
| 134 | |
| OLD | NEW |