| Index: benchmark/before.dart.txt
|
| diff --git a/benchmark/benchmark.dart b/benchmark/before.dart.txt
|
| similarity index 94%
|
| copy from benchmark/benchmark.dart
|
| copy to benchmark/before.dart.txt
|
| index 3ab9d48272657fc864f93198592548a0c5b3364f..8a0e05312dba0a695b17fd8b9e29c5d976bab256 100644
|
| --- a/benchmark/benchmark.dart
|
| +++ b/benchmark/before.dart.txt
|
| @@ -1,72 +1,3 @@
|
| -// Copyright (c) 2014, 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.
|
| -
|
| -library dart_style.benchmark.benchmark;
|
| -
|
| -import 'dart:io';
|
| -
|
| -import 'package:dart_style/dart_style.dart';
|
| -
|
| -const NUM_TRIALS = 100;
|
| -const FORMATS_PER_TRIAL = 30;
|
| -
|
| -void main(List<String> args) {
|
| - var best = 99999999.0;
|
| -
|
| - // Run the benchmark several times. This ensures the VM is warmed up and lets
|
| - // us see how much variance there is.
|
| - for (var i = 0; i <= NUM_TRIALS; i++) {
|
| - var start = new DateTime.now();
|
| -
|
| - // For a single benchmark, format the source multiple times.
|
| - for (var j = 0; j < FORMATS_PER_TRIAL; j++) {
|
| - formatSource();
|
| - }
|
| -
|
| - var elapsed = new DateTime.now()
|
| - .difference(start).inMilliseconds / FORMATS_PER_TRIAL;
|
| -
|
| - // Keep track of the best run so far.
|
| - if (elapsed >= best) continue;
|
| - best = elapsed;
|
| -
|
| - // Don't print the first run. It's always terrible since the VM hasn't
|
| - // warmed up yet.
|
| - if (i == 0) continue;
|
| - printResult("Run ${padLeft('#$i', 3)}", elapsed);
|
| - }
|
| -
|
| - printResult("Best ", best);
|
| -}
|
| -
|
| -void printResult(String label, double time) {
|
| - print("$label: ${padLeft(time.toStringAsFixed(2), 4)}ms "
|
| - "${'=' * ((time * 5).toInt())}");
|
| -}
|
| -
|
| -String padLeft(input, int length) {
|
| - var result = input.toString();
|
| - if (result.length < length) {
|
| - result = " " * (length - result.length) + result;
|
| - }
|
| -
|
| - return result;
|
| -}
|
| -
|
| -void formatSource() {
|
| - var formatter = new DartFormatter();
|
| - var result = formatter.format(source);
|
| -
|
| - // Sanity check to make sure the output is what we expect and to make sure
|
| - // the VM doesn't optimize "dead" code away.
|
| - if (result.length != 29791) {
|
| - print("Incorrect output (length ${result.length}):\n$result");
|
| - exit(1);
|
| - }
|
| -}
|
| -
|
| -const source = r"""
|
| // Copyright (c) 2012, 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.
|
| @@ -881,5 +812,4 @@ void _validateSdkConstraint(Pubspec pubspec) {
|
| pubspec.name,
|
| 'Package ${pubspec.name} requires SDK version '
|
| '${pubspec.environment.sdkVersion} but the current SDK is ' '${sdk.version}.');
|
| -}
|
| -""";
|
| +}
|
|
|