blob: 4907f4e4437863d9b73f0d5a49c5c0f18271eb8a [file] [log] [blame]
// Copyright (c) 2019, 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:async' show Future;
import 'dart:io' show File, Platform;
import 'package:kernel/target/targets.dart' show NoneTarget, TargetFlags;
import 'binary_md_dill_reader.dart' show BinaryMdDillReader;
import 'incremental_load_from_dill_suite.dart'
show getOptions, normalCompileToBytes;
import 'utils/io_utils.dart' show computeRepoDir;
main() async {
await testDart2jsCompile();
Future<void> testDart2jsCompile() async {
final Uri dart2jsUrl = Uri.base.resolve("pkg/compiler/bin/dart2js.dart");
Stopwatch stopwatch = new Stopwatch()..start();
List<int> bytes = await normalCompileToBytes(dart2jsUrl,
options: getOptions(target: new NoneTarget(new TargetFlags())));
print("Compiled dart2js in ${stopwatch.elapsedMilliseconds} ms");
File binaryMd = new File("$repoDir/pkg/kernel/");
String binaryMdContent = binaryMd.readAsStringSync();
print("Read in ${stopwatch.elapsedMilliseconds} ms");
BinaryMdDillReader binaryMdDillReader =
new BinaryMdDillReader(binaryMdContent, bytes);
print("Parsed dart2js compiled bytes via "
"in ${stopwatch.elapsedMilliseconds} ms");
final String repoDir = computeRepoDir();
String get dartVm => Platform.executable;