diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-08-20 15:36:06 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-08-20 15:36:06 -0700 |
commit | 0dd575611af82001fe9a5a9f5b0d6a2e25762255 (patch) | |
tree | 9d83112f235c18dfc731ffea753293f7941e7424 | |
parent | 1f666759fe6170a7be2399e794a4adfa32a82b1e (diff) |
PROFILE_MAIN_LOOP option
-rw-r--r-- | src/library_browser.js | 18 | ||||
-rw-r--r-- | src/settings.js | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index f285a6d2..d0fdeef0 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: [], @@ -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; diff --git a/src/settings.js b/src/settings.js index 09b17c83..75b30003 100644 --- a/src/settings.js +++ b/src/settings.js @@ -115,6 +115,8 @@ var LIBRARY_DEBUG = 0; // Print out when we enter a library call (library*.js). var GL_DEBUG = 0; // Print out all calls into WebGL. As with LIBRARY_DEBUG, you can set a runtime // option, in this case GL.debug. +var PROFILE_MAIN_LOOP = 0; // Profile the function called in set_main_loop + var DISABLE_EXCEPTION_CATCHING = 0; // Disables generating code to actually catch exceptions. If the code you // are compiling does not actually rely on catching exceptions (but the // compiler generates code for it, maybe because of stdlibc++ stuff), |