Files
sdk/pkg/kernel/test/frontend_bench.dart
T
Asger Feldthaus 709c1e0b75 Store library paths relative to a given application root folder.
In kernel, library import URIs now support an "app" scheme as an
alternative to the "file" scheme, representing a path relative to
the application root.

dartk takes an --app-root flag giving the application root. If none
is given, file URIs are used instead.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/60adb852ad706ecf9424c77d47fa05583d543def

Review URL: https://codereview.chromium.org/2532053005 .

Reverted: https://github.com/dart-lang/sdk/commit/bb540416f27c39d75ee7f243899939fc37a2cd03
2016-11-30 10:39:48 +01: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:kernel/analyzer/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));
Repository repository = new Repository();
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');
});
}