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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 part 'constant_map.dart'; 9 part 'constant_map.dart';
10 part 'native_helper.dart'; 10 part 'native_helper.dart';
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 if ((length is !int) || (length < 0)) { 528 if ((length is !int) || (length < 0)) {
529 throw new ArgumentError(length); 529 throw new ArgumentError(length);
530 } 530 }
531 var result = JS('=List', r'new Array(#)', length); 531 var result = JS('=List', r'new Array(#)', length);
532 JS('void', r'#.fixed$length = #', result, true); 532 JS('void', r'#.fixed$length = #', result, true);
533 return result; 533 return result;
534 } 534 }
535 535
536 static num dateNow() => JS('num', r'Date.now()'); 536 static num dateNow() => JS('num', r'Date.now()');
537 537
538 static num numMicroseconds() {
539 var performance = JS('var', 'window.performance');
ngeoffray 2012/11/21 08:32:53 Shouldn't you check that window is defined too?
540 if (performance != null &&
541 JS('bool', 'typeof #.webkitNow == "function"', performance)) {
542 return JS('num', '#.webkitNow()', performance);
543 } else {
544 return 1000 * dateNow();
545 }
546 }
547
538 static String stringFromCharCodes(charCodes) { 548 static String stringFromCharCodes(charCodes) {
539 for (var i in charCodes) { 549 for (var i in charCodes) {
540 if (i is !int) throw new ArgumentError(i); 550 if (i is !int) throw new ArgumentError(i);
541 } 551 }
542 return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes); 552 return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes);
543 } 553 }
544 554
545 static String getTimeZoneName(receiver) { 555 static String getTimeZoneName(receiver) {
546 // When calling toString on a Date it will emit the timezone in parenthesis. 556 // When calling toString on a Date it will emit the timezone in parenthesis.
547 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)". 557 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 return typeName == other.typeName; 1546 return typeName == other.typeName;
1537 } 1547 }
1538 } 1548 }
1539 1549
1540 String getRuntimeTypeString(var object) { 1550 String getRuntimeTypeString(var object) {
1541 var typeInfo = JS('var', r'#.builtin$typeInfo', object); 1551 var typeInfo = JS('var', r'#.builtin$typeInfo', object);
1542 return JS('String', r'#.runtimeType', typeInfo); 1552 return JS('String', r'#.runtimeType', typeInfo);
1543 } 1553 }
1544 1554
1545 createRuntimeType(String name) => new TypeImpl(name); 1555 createRuntimeType(String name) => new TypeImpl(name);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698