Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 | 2 |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 /** The entry point for the analyzer. */ | 7 /** The entry point for the analyzer. */ |
| 8 library analyzer; | 8 library analyzer; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import 'dart:convert'; | 11 import 'dart:convert'; |
| 12 import 'dart:io'; | 12 import 'dart:io'; |
| 13 | 13 |
| 14 import 'package:analyzer/src/analyzer_impl.dart'; | 14 import 'package:analyzer/src/analyzer_impl.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/error.dart'; | 16 import 'package:analyzer/src/generated/error.dart'; |
| 17 import 'package:analyzer/src/generated/java_core.dart' show JavaSystem; | 17 import 'package:analyzer/src/generated/java_core.dart' show JavaSystem; |
| 18 import 'package:analyzer/options.dart'; | 18 import 'package:analyzer/options.dart'; |
| 19 | 19 |
| 20 void main(args) { | 20 void main(args) { |
| 21 CommandLineOptions options = CommandLineOptions.parse(args); | 21 CommandLineOptions options = CommandLineOptions.parse(args); |
| 22 if (options.shouldBatch) { | 22 if (options.shouldBatch) { |
| 23 BatchRunner.runAsBatch(args, (List<String> args) { | 23 BatchRunner.runAsBatch(args, (List<String> args) { |
| 24 CommandLineOptions options = CommandLineOptions.parse(args); | 24 CommandLineOptions options = CommandLineOptions.parse(args); |
| 25 return _runAnalyzer(options, false); | 25 return _runAnalyzer(options, false); |
| 26 }); | 26 }); |
| 27 } else if (options.perf) { | |
|
scheglov
2014/04/07 19:20:30
I don't understand this.
Do nothing when --perf is
Brian Wilkerson
2014/04/07 20:05:17
Good catch! I had originally though I'd need to fo
| |
| 28 | |
| 27 } else { | 29 } else { |
| 28 _runAnalyzer(options, false); | 30 _runAnalyzer(options, false); |
| 29 } | 31 } |
| 30 } | 32 } |
| 31 | 33 |
| 32 _runAnalyzer(CommandLineOptions options, [bool async = true]) { | 34 _runAnalyzer(CommandLineOptions options, [bool async = true]) { |
| 33 int startTime = JavaSystem.currentTimeMillis(); | |
| 34 if (!options.machineFormat) { | 35 if (!options.machineFormat) { |
| 35 stdout.writeln("Analyzing ${options.sourceFiles}..."); | 36 stdout.writeln("Analyzing ${options.sourceFiles}..."); |
| 36 } | 37 } |
| 37 ErrorSeverity allResult = ErrorSeverity.NONE; | 38 ErrorSeverity allResult = ErrorSeverity.NONE; |
| 38 String sourcePath = options.sourceFiles[0]; | 39 String sourcePath = options.sourceFiles[0]; |
| 39 sourcePath = sourcePath.trim(); | 40 sourcePath = sourcePath.trim(); |
| 40 // check that file exists | 41 // check that file exists |
| 41 if (!new File(sourcePath).existsSync()) { | 42 if (!new File(sourcePath).existsSync()) { |
| 42 print('File not found: $sourcePath'); | 43 print('File not found: $sourcePath'); |
| 43 exitCode = ErrorSeverity.ERROR.ordinal; | 44 exitCode = ErrorSeverity.ERROR.ordinal; |
| 44 return ErrorSeverity.ERROR; | 45 return ErrorSeverity.ERROR; |
| 45 } | 46 } |
| 46 // check that file is Dart file | 47 // check that file is Dart file |
| 47 if (!AnalysisEngine.isDartFileName(sourcePath)) { | 48 if (!AnalysisEngine.isDartFileName(sourcePath)) { |
| 48 print('$sourcePath is not a Dart file'); | 49 print('$sourcePath is not a Dart file'); |
| 49 exitCode = ErrorSeverity.ERROR.ordinal; | 50 exitCode = ErrorSeverity.ERROR.ordinal; |
| 50 return ErrorSeverity.ERROR; | 51 return ErrorSeverity.ERROR; |
| 51 } | 52 } |
| 52 // do analyze | 53 // do analyze |
| 54 if (options.warmPerf) { | |
| 55 int startTime = JavaSystem.currentTimeMillis(); | |
| 56 AnalyzerImpl analyzer = new AnalyzerImpl(sourcePath, options, startTime); | |
| 57 analyzer.analyzeSync(printMode: 2); | |
| 58 | |
| 59 for (int i = 0; i < 8; i++) { | |
| 60 startTime = JavaSystem.currentTimeMillis(); | |
| 61 analyzer = new AnalyzerImpl(sourcePath, options, startTime); | |
| 62 analyzer.analyzeSync(printMode: 0); | |
| 63 } | |
| 64 | |
| 65 PerformanceStatistics.reset(); | |
| 66 startTime = JavaSystem.currentTimeMillis(); | |
| 67 analyzer = new AnalyzerImpl(sourcePath, options, startTime); | |
| 68 return analyzer.analyzeSync(); | |
| 69 } | |
| 70 int startTime = JavaSystem.currentTimeMillis(); | |
| 53 AnalyzerImpl analyzer = new AnalyzerImpl(sourcePath, options, startTime); | 71 AnalyzerImpl analyzer = new AnalyzerImpl(sourcePath, options, startTime); |
| 54 if (async) { | 72 if (async) { |
| 55 return analyzer.analyzeAsync(); | 73 return analyzer.analyzeAsync(); |
| 56 } else { | 74 } else { |
| 57 return analyzer.analyzeSync(); | 75 return analyzer.analyzeSync(); |
| 58 } | 76 } |
| 59 } | 77 } |
| 60 | 78 |
| 61 typedef ErrorSeverity BatchRunnerHandler(List<String> args); | 79 typedef ErrorSeverity BatchRunnerHandler(List<String> args); |
| 62 | 80 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 stdout.writeln('>>> TEST $resultPassString ${stopwatch.elapsedMillisecon ds}ms'); | 127 stdout.writeln('>>> TEST $resultPassString ${stopwatch.elapsedMillisecon ds}ms'); |
| 110 } catch (e, stackTrace) { | 128 } catch (e, stackTrace) { |
| 111 stderr.writeln(e); | 129 stderr.writeln(e); |
| 112 stderr.writeln(stackTrace); | 130 stderr.writeln(stackTrace); |
| 113 stderr.writeln('>>> EOF STDERR'); | 131 stderr.writeln('>>> EOF STDERR'); |
| 114 stdout.writeln('>>> TEST CRASH'); | 132 stdout.writeln('>>> TEST CRASH'); |
| 115 } | 133 } |
| 116 }); | 134 }); |
| 117 } | 135 } |
| 118 } | 136 } |
| OLD | NEW |