diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-05-14 16:49:25 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-05-14 16:49:25 -0700 |
commit | 354a88d763284fae92a59d311f8562542ad10a97 (patch) | |
tree | b0eb1e9777246c6ad002c896753b5082ef249fc4 | |
parent | faf13f78df6aba1f4eddcca1f0778eaa878e1495 (diff) |
emscripten_get_now
-rw-r--r-- | src/library_browser.js | 8 | ||||
-rw-r--r-- | system/include/emscripten.h | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index c42cef14..d49c4103 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -241,6 +241,14 @@ mergeInto(LibraryManager.library, { } } styleSheet.insertRule('canvas.emscripten { border: 1px solid black; cursor: none; }', 0); + }, + + emscripten_get_now: function() { + if (window['performance'] && window['performance']['now']) { + return window['performance']['now'](); + } else { + return Date.now(); + } } }); diff --git a/system/include/emscripten.h b/system/include/emscripten.h index a4f15868..d0e6cc46 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten.h @@ -65,6 +65,15 @@ void emscripten_async_call(void (*func)(), int millis) { void emscripten_hide_mouse(); /* + * Returns the highest-precision representation of the + * current time that the browser provides. This uses either + * Date.now or performance.now. The result is *not* an + * absolute time, and is only meaningful in comparison to + * other calls to this function. The unit is ms. + */ +float emscripten_get_now(); + +/* * This macro-looking function will cause Emscripten to * generate a comment in the generated code. * XXX This is deprecated for now, because it requires us to |