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

Side by Side Diff: samples/third_party/dromaeo/common/BenchUtil.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of common; 5 part of common;
6 6
7 // Misc benchmark-related utility functions. 7 // Misc benchmark-related utility functions.
8 8
9 class BenchUtil { 9 class BenchUtil {
10 static int get now { 10 static int get now {
11 return new Date.now().millisecondsSinceEpoch; 11 return new Date.now().millisecondsSinceEpoch;
12 } 12 }
13 13
14 static Map<String, Object> deserialize(String data) { 14 static Map<String, Object> deserialize(String data) {
15 return parseJson(data); 15 return parseJson(data);
16 } 16 }
17 17
18 static String serialize(Object obj) { 18 static String serialize(Object obj) {
19 return jsonStringify(obj); 19 return jsonStringify(obj);
20 } 20 }
21 21
22 // Shuffle a list randomly. 22 // Shuffle a list randomly.
23 static void shuffle(List<Object> list) { 23 static void shuffle(List<Object> list) {
24 int len = list.length - 1; 24 int len = list.length - 1;
25 for (int i = 0; i < len; i++) { 25 for (int i = 0; i < len; i++) {
26 int index = (Math.random() * (len - i)).toInt() + i; 26 int index = (Math.random() * (len - i)).truncate() + i;
27 Object tmp = list[i]; 27 Object tmp = list[i];
28 list[i] = list[index]; 28 list[i] = list[index];
29 list[index] = tmp; 29 list[index] = tmp;
30 } 30 }
31 } 31 }
32 32
33 static String formatGolemData(String prefix, Map<String, num> results) { 33 static String formatGolemData(String prefix, Map<String, num> results) {
34 List<String> elements = new List<String>(); 34 List<String> elements = new List<String>();
35 results.forEach((String name, num score) { 35 results.forEach((String name, num score) {
36 elements.add('"${prefix}/${name}":${score}'); 36 elements.add('"${prefix}/${name}":${score}');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 for (Match match in new RegExp(pattern).allMatches(s)) { 75 for (Match match in new RegExp(pattern).allMatches(s)) {
76 sb.add(s.substring(pos, match.start)); 76 sb.add(s.substring(pos, match.start));
77 sb.add(replacement(match)); 77 sb.add(replacement(match));
78 pos = match.end; 78 pos = match.end;
79 } 79 }
80 sb.add(s.substring(pos)); 80 sb.add(s.substring(pos));
81 81
82 return sb.toString(); 82 return sb.toString();
83 } 83 }
84 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698