Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11417110: Let stopwatch use window.performance.now when available. Fix for: http://code.google.com/p/dart/iss… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index 279ee270849d8dd3f34dc94de87ee8f05a6af0d6..52d2f67198d0cfcede2005bf2f66f1deb950975d 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -535,6 +535,16 @@ class Primitives {
static num dateNow() => JS('num', r'Date.now()');
+ static num numMicroseconds() {
+ var performance = JS('var', 'window.performance');
ngeoffray 2012/11/21 08:32:53 Shouldn't you check that window is defined too?
+ if (performance != null &&
+ JS('bool', 'typeof #.webkitNow == "function"', performance)) {
+ return JS('num', '#.webkitNow()', performance);
+ } else {
+ return 1000 * dateNow();
+ }
+ }
+
static String stringFromCharCodes(charCodes) {
for (var i in charCodes) {
if (i is !int) throw new ArgumentError(i);

Powered by Google App Engine
This is Rietveld 408576698