<commit_before>// Copyright (c) 2015, 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.

import 'package:linter/src/io.dart';
import 'package:unittest/unittest.dart';

import 'config_test.dart' as config_test;
import 'formatter_test.dart' as formatter_test;
import 'integration_test.dart' as integration_test;
import 'io_test.dart' as io_test;
import 'linter_test.dart' as linter_test;
import 'mocks.dart';
import 'project_test.dart' as project_test;
import 'pub_test.dart' as pub_test;

main() {
  // Tidy up the unittest output.
  filterStacks = true;
  formatStacks = true;

  // useCompactVMConfiguration();
  // useTimingConfig();

  // Redirect output.
  outSink = new MockIOSink();

  linter_test.main();
  pub_test.main();
  io_test.main();
  formatter_test.main();
  config_test.main();
  project_test.main();
  integration_test.main();
}

void useTimingConfig() {
  unittestConfiguration = new TimingTestConfig();
}

class TimingTestConfig extends SimpleConfiguration {
  final stopwatch = new Stopwatch();

  @override
  void onDone(bool success) {
    stopwatch.stop();
    super.onDone(success);
    print('Total time = ${stopwatch.elapsedMilliseconds / 1000} seconds.');
  }

  @override
  void onStart() => stopwatch.start();
}<commit_msg>Timing tweaks.<commit_after>// Copyright (c) 2015, 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.

import 'package:linter/src/io.dart';
import 'package:unittest/unittest.dart';

import 'config_test.dart' as config_test;
import 'formatter_test.dart' as formatter_test;
import 'integration_test.dart' as integration_test;
import 'io_test.dart' as io_test;
import 'linter_test.dart' as linter_test;
import 'mocks.dart';
import 'project_test.dart' as project_test;
import 'pub_test.dart' as pub_test;

main() {
  // Tidy up the unittest output.
  filterStacks = true;
  formatStacks = true;

  // useCompactVMConfiguration();
  //useTimingConfig();

  // Redirect output.
  outSink = new MockIOSink();

  linter_test.main();
  pub_test.main();
  io_test.main();
  formatter_test.main();
  config_test.main();
  project_test.main();
  integration_test.main();
}

void useTimingConfig() {
  unittestConfiguration = new TimingTestConfig();
}

class TimingTestConfig extends SimpleConfiguration {
  /// Tests that are this fast (in seconds) are uninteresting.
  static const threshold = 0;

  /// Clocks total elapsed time.
  final bigWatch = new Stopwatch();

  /// Clocks individual tests.
  final testWatch = new Stopwatch();

  /// Maps tests to times.
  final watches = <TestCase, double>{};

  @override
  String formatResult(TestCase testCase) {
    var result = new StringBuffer();
    result.write(testCase.result.toUpperCase());
    result.write(": ");
    result.write(testCase.description);
    var elapsed = watches[testCase];
    if (elapsed > threshold) {
      result.write(' [$elapsed]');
    }
    result.write("\n");

    if (testCase.message != '') {
      result.write(indent(testCase.message));
      result.write("\n");
    }

    if (testCase.stackTrace != null) {
      result.write(indent(testCase.stackTrace.toString()));
      result.write("\n");
    }
    return result.toString();
  }

  String indent(String str) =>
      str.replaceAll(new RegExp("^", multiLine: true), "  ");

  @override
  void onDone(bool success) {
    bigWatch.stop();
    super.onDone(success);
    print('Total time = ${bigWatch.elapsedMilliseconds / 1000} seconds.');
  }

  @override
  void onStart() => bigWatch.start();

  @override
  void onTestResult(TestCase externalTestCase) {
    watches[externalTestCase] = testWatch.elapsedMilliseconds / 1000;
    super.onTestResult(externalTestCase);
  }

  @override
  void onTestStart(TestCase testCase) {
    testWatch.reset();
    testWatch.start();
    super.onTestStart(testCase);
  }
}
{'fraction_non_alphanumeric': 0.12720588235294117, 'fraction_numerical': 0.005147058823529412, 'mean_word_length': 3.940677966101695, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7098017', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1282, 'n_words': 332}