OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 yaml.benchmark.benchmark; | 5 library yaml.benchmark.benchmark; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
11 | 11 |
12 import 'package:yaml/yaml.dart'; | 12 import 'package:yaml/yaml.dart'; |
13 | 13 |
14 const numTrials = 10000000; | 14 const numTrials = 100; |
15 const runsPerTrial = 1000; | 15 const runsPerTrial = 1000; |
16 | 16 |
17 final source = loadFile("input.yaml"); | 17 final source = loadFile("input.yaml"); |
18 final expected = loadFile("output.json"); | 18 final expected = loadFile("output.json"); |
19 | 19 |
20 void main(List<String> args) { | 20 void main(List<String> args) { |
21 var best = double.INFINITY; | 21 var best = double.INFINITY; |
22 | 22 |
23 // Run the benchmark several times. This ensures the VM is warmed up and lets | 23 // Run the benchmark several times. This ensures the VM is warmed up and lets |
24 // us see how much variance there is. | 24 // us see how much variance there is. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 String padLeft(input, int length) { | 67 String padLeft(input, int length) { |
68 var result = input.toString(); | 68 var result = input.toString(); |
69 if (result.length < length) { | 69 if (result.length < length) { |
70 result = " " * (length - result.length) + result; | 70 result = " " * (length - result.length) + result; |
71 } | 71 } |
72 | 72 |
73 return result; | 73 return result; |
74 } | 74 } |
OLD | NEW |