Files
sdk/pkg/kernel/test/frontend_bench.dart
T
Paul Berry 685045d619 Start unraveling circularities between analyzer and front_end/kernel.
This CL moves many of the files from
pkg/front_end/lib/src/fasta/analyzer/ to pkg/analyzer/lib/src/fasta/.
It also moves two files from pkg/kernel/lib/analyzer/ to
pkg/analyzer/lib/src/kernel/.

This reduces the amount of circularity between analyzer and
front_end/kernel so that there are no files in front_end or kernel
which are both dependend upon by analyzer and depend upon analyzer.  I
will clean up the remaining circularities in future CLs.

There should be no functional change.

R=ahe@google.com, asgerf@google.com, kmillikin@google.com, scheglov@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2756593004 .
2017-03-17 05:56:06 -07:00

68 lines
1.9 KiB
Dart

// Copyright (c) 2016, 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 'dart:io';
import 'package:analyzer/src/context/cache.dart';
import 'package:analyzer/task/model.dart';
import 'package:args/args.dart';
import 'package:analyzer/src/kernel/loader.dart';
import 'package:kernel/kernel.dart';
import 'package:package_config/discovery.dart';
ArgParser parser = new ArgParser()
..addOption('sdk',
help: 'Path to Dart SDK', valueHelp: 'path', defaultsTo: '/usr/lib/dart')
..addOption('packages',
abbr: 'p',
help: 'Path to the packages folder or .packages file',
valueHelp: 'path')
..addFlag('strong', help: 'Use strong mode');
String get usage => '''
Usage: frontend_bench [options] FILE.dart
Benchmark the analyzer-based frontend.
Options:
${parser.options}
''';
main(List<String> args) {
if (args.length == 0) {
print(usage);
exit(1);
}
ArgResults options = parser.parse(args);
if (options.rest.length != 1) {
print('Exactly one file must be given');
exit(1);
}
String sdk = options['sdk'];
String packagePath = options['packages'];
bool strongMode = options['strong'];
String path = options.rest.single;
var uri = new Uri(scheme: 'file', path: new File(path).absolute.path);
var packages =
getPackagesDirectory(new Uri(scheme: 'file', path: packagePath));
Program repository = new Program();
new DartLoader(
repository,
new DartOptions(
strongMode: strongMode, sdk: sdk, packagePath: packagePath),
packages)
.loadProgram(uri);
CacheEntry.recomputedCounts.forEach((key, value) {
print('Recomputed $key $value times');
});
AnalysisTask.stopwatchMap.forEach((key, Stopwatch watch) {
print('$key took ${watch.elapsedMilliseconds} ms');
});
}