diff options
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index f285a6d2..11c9bf2c 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -10,6 +10,10 @@ mergeInto(LibraryManager.library, { $Browser: { mainLoop: { scheduler: null, +#if PROFILE_MAIN_LOOP + meanTime: 0, + lastReport: 0, +#endif shouldPause: false, paused: false, queue: [], @@ -93,7 +97,7 @@ mergeInto(LibraryManager.library, { } if (!b) { var bb = new Browser.BlobBuilder(); - bb.append(byteArray.buffer); + bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range b = bb.getBlob(); } var url = Browser.URLObject.createObjectURL(b); @@ -394,7 +398,21 @@ mergeInto(LibraryManager.library, { Browser.mainLoop.shouldPause = false; return; } + +#if PROFILE_MAIN_LOOP + var start = performance.now(); +#endif jsFunc(); +#if PROFILE_MAIN_LOOP + var now = performance.now(); + var time = now - start; + Browser.mainLoop.meanTime = (Browser.mainLoop.meanTime*9 + time)/10; + if (now - Browser.mainLoop.lastReport > 1000) { + console.log('main loop time: ' + Browser.mainLoop.meanTime); + Browser.mainLoop.lastReport = now; + } +#endif + if (Browser.mainLoop.shouldPause) { // catch pauses from the main loop itself Browser.mainLoop.paused = true; |