()
| 282 | div.innerHTML = "<div style='border: 2px solid black; padding: 2px;'><canvas style='border: 1px solid black; margin-left: auto; margin-right: auto; display: block;' id='memoryprofiler_canvas' width='100%' height='50'></canvas><input type='checkbox' id='showHeapResizes' onclick='emscriptenMemoryProfiler.updateUi()'>Display heap and sbrk() resizes. Filter sbrk() and heap resize callstacks by keywords: <input type='text' id='sbrkFilter'>(reopen page with ?sbrkFilter=foo,bar query params to prepopulate this list)<br/>Track all allocation sites larger than <input id='memoryprofiler_min_tracked_alloc_size' type=number value="+emscriptenMemoryProfiler.trackedCallstackMinSizeBytes+"></input> bytes, and all allocation sites with more than <input id='memoryprofiler_min_tracked_alloc_count' type=number value="+emscriptenMemoryProfiler.trackedCallstackMinAllocCount+"></input> outstanding allocations. (visit this page via URL query params foo.html?trackbytes=1000&trackcount=100 to apply custom thresholds starting from page load)<br/><div id='memoryprofiler_summary'></div><input id='memoryprofiler_clear_alloc_stats' type='button' value='Clear alloc stats' ></input><br />Sort allocations by:<select id='memoryProfilerSort'><option value='bytes'>Bytes</option><option value='count'>Count</option><option value='fixed'>Fixed</option></select><div id='memoryprofiler_ptrs'></div>"; |
| 283 | } |
| 284 | var populateHtmlBody = function() { |
| 285 | if (div) { |
| 286 | document.body.appendChild(div); |
| 287 | |
| 288 | function getValueOfParam(key) { |
| 289 | var results = (new RegExp("[\\?&]"+key+"=([^&#]*)")).exec(location.href); |
| 290 | return results ? results[1] : ''; |
| 291 | } |
| 292 | // Allow specifying a precreated filter in page URL ?query parameters for convenience. |
| 293 | if (document.getElementById('sbrkFilter').value = getValueOfParam('sbrkFilter')) { |
| 294 | document.getElementById('showHeapResizes').checked = true; |
| 295 | } |
| 296 | } |
| 297 | var self = emscriptenMemoryProfiler; |
| 298 | self.memoryprofiler_summary = document.getElementById('memoryprofiler_summary'); |
| 299 | self.memoryprofiler_ptrs = document.getElementById('memoryprofiler_ptrs'); |
| 300 | |
| 301 | document.getElementById('memoryprofiler_min_tracked_alloc_size').addEventListener("change", function(e) { self.trackedCallstackMinSizeBytes=parseInt(this.value, undefined /* https://github.com/google/closure-compiler/issues/3230 / https://github.com/google/closure-compiler/issues/3548 */); }); |
| 302 | document.getElementById('memoryprofiler_min_tracked_alloc_count').addEventListener("change", function(e) { self.trackedCallstackMinAllocCount=parseInt(this.value, undefined); }); |
| 303 | document.getElementById('memoryprofiler_clear_alloc_stats').addEventListener("click", (e) => {self.allocationsAtLoc = {}; self.allocationSitePtrs = {};}); |
| 304 | self.canvas = document.getElementById('memoryprofiler_canvas'); |
| 305 | self.canvas.width = document.documentElement.clientWidth - 32; |
| 306 | self.drawContext = self.canvas.getContext('2d'); |
| 307 | |
| 308 | self.updateUi(); |
| 309 | setInterval(() => emscriptenMemoryProfiler.updateUi(), self.uiUpdateIntervalMsecs); |
| 310 | |
| 311 | }; |
| 312 | // User might initialize memoryprofiler in the <head> of a page, when |
| 313 | // document.body does not yet exist. In that case, delay initialization |
| 314 | // of the memoryprofiler UI until page has loaded |
no test coverage detected