OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation | 4 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation |
5 | 5 |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 | 7 |
8 test1(String a, String b) { | 8 test1(String a, String b) { |
9 return a == b; | 9 return a == b; |
10 } | 10 } |
11 | 11 |
12 var LEN = 500; | 12 var LEN = 500; |
13 | 13 |
14 var ITER = 100000 / LEN; | 14 var ITER = 100000 / LEN; |
15 | 15 |
16 measure(fn, a, b) { | 16 measure(fn, a, b) { |
17 for (var i = 0; i < ITER; i++) { | 17 for (var i = 0; i < ITER; i++) { |
18 Expect.equals(true, fn(a, b)); | 18 Expect.equals(true, fn(a, b)); |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 main() { | 22 main() { |
23 var n = LEN; | 23 var n = LEN; |
24 StringBuffer s = new StringBuffer(); | 24 StringBuffer s = new StringBuffer(); |
25 for (var i=0; i < n; ++i) s.write("A"); | 25 for (var i = 0; i < n; ++i) s.write("A"); |
26 String t = s.toString(); | 26 String t = s.toString(); |
27 String u = s.toString(); | 27 String u = s.toString(); |
28 String v = s.toString() + "\u1234"; | 28 String v = s.toString() + "\u1234"; |
29 String w = s.toString() + "\u1234"; | 29 String w = s.toString() + "\u1234"; |
30 for (var i=0; i<10; i++) measure(test1, t, u); | 30 for (var i = 0; i < 10; i++) measure(test1, t, u); |
31 for (var i=0; i<10; i++) measure(test1, v, w); | 31 for (var i = 0; i < 10; i++) measure(test1, v, w); |
32 } | 32 } |
OLD | NEW |