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

Unified Diff: samples/third_party/dromaeo/common/BenchUtil.dart

Issue 199003005: Package-ify Dromaeo and browser controller functionality (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months 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
« no previous file with comments | « samples/third_party/dromaeo/application.css ('k') | samples/third_party/dromaeo/common/Interval.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/third_party/dromaeo/common/BenchUtil.dart
diff --git a/samples/third_party/dromaeo/common/BenchUtil.dart b/samples/third_party/dromaeo/common/BenchUtil.dart
deleted file mode 100644
index 5a4b9c708928c22c1952a25fa15608dbac077ae1..0000000000000000000000000000000000000000
--- a/samples/third_party/dromaeo/common/BenchUtil.dart
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of common;
-
-// Misc benchmark-related utility functions.
-
-class BenchUtil {
- static int get now {
- return new DateTime.now().millisecondsSinceEpoch;
- }
-
- static Map<String, Object> deserialize(String data) {
- return JSON.decode(data);
- }
-
- static String serialize(Object obj) {
- return JSON.encode(obj);
- }
-
- // Shuffle a list randomly.
- static void shuffle(List<Object> list) {
- int len = list.length - 1;
- for (int i = 0; i < len; i++) {
- int index = (Math.random() * (len - i)).toInt() + i;
- Object tmp = list[i];
- list[i] = list[index];
- list[index] = tmp;
- }
- }
-
- static String formatGolemData(String prefix, Map<String, num> results) {
- List<String> elements = new List<String>();
- results.forEach((String name, num score) {
- elements.add('"${prefix}/${name}":${score}');
- });
- return serialize(elements);
- }
-
- static bool _inRange(int charCode, String start, String end) {
- return start.codeUnitAt(0) <= charCode && charCode <= end.codeUnitAt(0);
- }
-
- static const String DIGITS = '0123456789ABCDEF';
- static String _asDigit(int value) {
- return DIGITS[value];
- }
-
- static String encodeUri(final String s) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < s.length; i++) {
- final int charCode = s.codeUnitAt(i);
- final bool noEscape =
- _inRange(charCode, '0', '9') ||
- _inRange(charCode, 'a', 'z') ||
- _inRange(charCode, 'A', 'Z');
- if (noEscape) {
- sb.write(s[i]);
- } else {
- sb.write('%');
- sb.write(_asDigit((charCode >> 4) & 0xF));
- sb.write(_asDigit(charCode & 0xF));
- }
- }
- return sb.toString();
- }
-
- // TODO: use corelib implementation.
- static String replaceAll(String s, String pattern,
- String replacement(Match match)) {
- StringBuffer sb = new StringBuffer();
-
- int pos = 0;
- for (Match match in new RegExp(pattern).allMatches(s)) {
- sb.write(s.substring(pos, match.start));
- sb.write(replacement(match));
- pos = match.end;
- }
- sb.write(s.substring(pos));
-
- return sb.toString();
- }
-}
« no previous file with comments | « samples/third_party/dromaeo/application.css ('k') | samples/third_party/dromaeo/common/Interval.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698