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

Unified Diff: client/html/benchmarks/common/BenchUtil.dart

Issue 9845043: Rename client/{dom,html} to lib/{dom,html} . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « client/dom/templates/interface.darttemplate ('k') | client/html/benchmarks/common/Interval.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/benchmarks/common/BenchUtil.dart
===================================================================
--- client/html/benchmarks/common/BenchUtil.dart (revision 5796)
+++ client/html/benchmarks/common/BenchUtil.dart (working copy)
@@ -1,82 +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.
-
-// Misc benchmark-related utility functions.
-
-class BenchUtil {
- static int get now() {
- return new Date.now().value;
- }
-
- static Map<String, Object> deserialize(String data) {
- return JSON.parse(data);
- }
-
- static String serialize(Object obj) {
- return JSON.stringify(obj);
- }
-
- // Shuffle an array randomly.
- static void shuffle(Array<Object> array) {
- int len = array.length - 1;
- for (int i = 0; i < len; i++) {
- int index = (Math.random() * (len - i)).toInt() + i;
- Object tmp = array[i];
- array[i] = array[index];
- array[index] = tmp;
- }
- }
-
- static String formatGolemData(String prefix, Map<String, num> results) {
- Array<String> elements = new Array<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.charCodeAt(0) <= charCode && charCode <= end.charCodeAt(0);
- }
-
- static final 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.charCodeAt(i);
- final bool noEscape =
- _inRange(charCode, '0', '9') ||
- _inRange(charCode, 'a', 'z') ||
- _inRange(charCode, 'A', 'Z');
- if (noEscape) {
- sb.add(s[i]);
- } else {
- sb.add('%');
- sb.add(_asDigit((charCode >> 4) & 0xF));
- sb.add(_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.add(s.substring(pos, match.start()));
- sb.add(replacement(match));
- pos = match.end();
- }
- sb.add(s.substringToEnd(pos));
-
- return sb.toString();
- }
-}
« no previous file with comments | « client/dom/templates/interface.darttemplate ('k') | client/html/benchmarks/common/Interval.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698