Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/dart2js_profile_many.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/dart2js_profile_many.dart b/sdk/lib/_internal/compiler/implementation/dart2js_profile_many.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b85fd0d0be922c9a5a81f32354bd12ba8b9382d1 |
| --- /dev/null |
| +++ b/sdk/lib/_internal/compiler/implementation/dart2js_profile_many.dart |
| @@ -0,0 +1,60 @@ |
| +// 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 dart2js.profile_many; |
| + |
| +import 'dart2js.dart' as cmdline; |
| +import 'dart:async'; |
| + |
| +const String USAGE = |
| +""" |
| +Usage: dart2js_profile_many.dart [OPTIONS] [FILES] |
| + |
| +Invokes dart2js separately for each file using the given options. |
| +This for profiling multiple compilations in the Dart Observatory. |
|
sigurdm
2014/05/27 12:05:34
This for => This is for
asgerf
2014/05/27 12:25:33
Done.
|
| +"""; |
| + |
| +printUsage() { |
| + print(USAGE); |
| +} |
| + |
| +void main(List<String> args) { |
| + |
| + List options = []; |
| + List files = []; |
| + |
| + for (String arg in args) { |
| + if (arg.startsWith('-')) { |
| + options.add(arg); |
| + } else { |
| + files.add(arg); |
| + } |
| + } |
| + |
| + if (files.length == 0) { |
| + printUsage(); |
| + return; |
| + } |
| + |
| + cmdline.exitFunc = (code) { |
| + throw "Exit with code $code"; |
| + }; |
| + |
| + compileFile(int index) { |
|
sigurdm
2014/05/27 12:05:34
Maybe iterating through the files and compiling ea
asgerf
2014/05/27 12:25:33
Much better, thanks.
|
| + if (index == files.length) { |
| + print("Done"); |
| + return; |
| + } |
| + String file = files[index]; |
| + List subargs = []; |
| + subargs.addAll(options); |
| + subargs.add(file); |
| + Future future = cmdline.compilerMain(subargs); |
| + future.catchError((e) { }) |
| + .then((_) { compileFile(index+1); }); |
| + } |
| + |
| + compileFile(0); |
| + |
| +} |