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

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: fix return statement 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..9f657752846616e032cd0f3119dff0987688df1a 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -535,6 +535,18 @@ class Primitives {
static num dateNow() => JS('num', r'Date.now()');
+ static num numMicroseconds() {
+ var theWindow = JS('var', 'window');
Lasse Reichstein Nielsen 2012/11/22 11:26:48 This read will throw if 'window' is not there. Con
ahe 2012/11/22 12:54:46 You don't have to call the variable theWindow. We
+ if (theWindow != null) {
+ var performance = JS('var', 'window.performance');
+ if (performance != null &&
+ JS('bool', 'typeof #.webkitNow == "function"', performance)) {
+ return JS('num', '#.webkitNow()', performance);
+ }
+ }
+ 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