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

Side by Side Diff: benchmark/benchmark.dart

Issue 1182953003: Eat some dogfood! (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | bin/format.dart » ('j') | lib/src/source_visitor.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 library dart_style.benchmark.benchmark; 5 library dart_style.benchmark.benchmark;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 10
(...skipping 15 matching lines...) Expand all
26 // us see how much variance there is. 26 // us see how much variance there is.
27 for (var i = 0; i <= NUM_TRIALS; i++) { 27 for (var i = 0; i <= NUM_TRIALS; i++) {
28 var start = new DateTime.now(); 28 var start = new DateTime.now();
29 29
30 // For a single benchmark, format the source multiple times. 30 // For a single benchmark, format the source multiple times.
31 var result; 31 var result;
32 for (var j = 0; j < FORMATS_PER_TRIAL; j++) { 32 for (var j = 0; j < FORMATS_PER_TRIAL; j++) {
33 result = formatSource(); 33 result = formatSource();
34 } 34 }
35 35
36 var elapsed = new DateTime.now() 36 var elapsed =
37 .difference(start).inMilliseconds / FORMATS_PER_TRIAL; 37 new DateTime.now().difference(start).inMilliseconds / FORMATS_PER_TRIAL;
38 38
39 // Keep track of the best run so far. 39 // Keep track of the best run so far.
40 if (elapsed >= best) continue; 40 if (elapsed >= best) continue;
41 best = elapsed; 41 best = elapsed;
42 42
43 // Sanity check to make sure the output is what we expect and to make sure 43 // Sanity check to make sure the output is what we expect and to make sure
44 // the VM doesn't optimize "dead" code away. 44 // the VM doesn't optimize "dead" code away.
45 if (result != expected) { 45 if (result != expected) {
46 print("Incorrect output:\n$result"); 46 print("Incorrect output:\n$result");
47 exit(1); 47 exit(1);
(...skipping 24 matching lines...) Expand all
72 result = " " * (length - result.length) + result; 72 result = " " * (length - result.length) + result;
73 } 73 }
74 74
75 return result; 75 return result;
76 } 76 }
77 77
78 String formatSource() { 78 String formatSource() {
79 var formatter = new DartFormatter(); 79 var formatter = new DartFormatter();
80 return formatter.format(source); 80 return formatter.format(source);
81 } 81 }
OLDNEW
« no previous file with comments | « no previous file | bin/format.dart » ('j') | lib/src/source_visitor.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698