Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: pkg/analyzer_cli/lib/src/perf_report.dart

Issue 1806263004: add --x-package-warnings-prefix option to dartanalyzer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: oops, check in all the test files Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer_cli/lib/src/options.dart ('k') | pkg/analyzer_cli/test/all.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer_cli.src.perf_report; 5 library analyzer_cli.src.perf_report;
6 6
7 import 'dart:convert' show JsonEncoder; 7 import 'dart:convert' show JsonEncoder;
8 import 'dart:io' show File, Platform; 8 import 'dart:io' show File, Platform;
9 9
10 import 'package:analyzer/src/generated/utilities_general.dart' 10 import 'package:analyzer/src/generated/utilities_general.dart'
11 show PerformanceTag; 11 show PerformanceTag;
12 import 'package:analyzer/task/model.dart' show AnalysisTask; 12 import 'package:analyzer/task/model.dart' show AnalysisTask;
13 import 'package:analyzer_cli/src/error_formatter.dart';
13 import 'package:analyzer_cli/src/options.dart' show CommandLineOptions; 14 import 'package:analyzer_cli/src/options.dart' show CommandLineOptions;
14 15
15 const _JSON = const JsonEncoder.withIndent(" "); 16 const _JSON = const JsonEncoder.withIndent(" ");
16 17
17 bool _isCheckedMode = () { 18 bool _isCheckedMode = () {
18 bool x = true; 19 bool x = true;
19 try { 20 try {
20 // Trigger an exception if we're in checked mode. 21 // Trigger an exception if we're in checked mode.
21 x = "" as dynamic; 22 x = "" as dynamic;
22 return x != ""; // return false; suppress unused variable warning 23 return x != ""; // return false; suppress unused variable warning
23 } catch (e) { 24 } catch (e) {
24 return true; 25 return true;
25 } 26 }
26 }(); 27 }();
27 28
28 String _osType = () { 29 String _osType = () {
29 if (Platform.isLinux) { 30 if (Platform.isLinux) {
30 return "linux"; 31 return "linux";
31 } else if (Platform.isMacOS) { 32 } else if (Platform.isMacOS) {
32 return "mac"; 33 return "mac";
33 } else if (Platform.isWindows) { 34 } else if (Platform.isWindows) {
34 return "windows"; 35 return "windows";
35 } else if (Platform.isAndroid) { 36 } else if (Platform.isAndroid) {
36 return "android"; 37 return "android";
37 } else { 38 } else {
38 return "unknown"; 39 return "unknown";
39 } 40 }
40 }(); 41 }();
41 42
42 String makePerfReport(int startTime, int endTime, CommandLineOptions options) { 43 String makePerfReport(int startTime, int endTime, CommandLineOptions options,
44 int analyzedFileCount, AnalysisStats stats) {
43 int totalTime = endTime - startTime; 45 int totalTime = endTime - startTime;
44 int otherTime = totalTime; 46 int otherTime = totalTime;
45 47
46 var platformJson = <String, dynamic>{ 48 var platformJson = <String, dynamic>{
47 'osType': _osType, 49 'osType': _osType,
48 'dartSdkVersion': Platform.version, 50 'dartSdkVersion': Platform.version,
49 'checkedMode': _isCheckedMode, 51 'checkedMode': _isCheckedMode,
50 }; 52 };
51 53
52 var optionsJson = <String, dynamic>{ 54 var optionsJson = <String, dynamic>{
53 'dartSdkPath': options.dartSdkPath, 55 'dartSdkPath': options.dartSdkPath,
54 'strongMode': options.strongMode, 56 'strongMode': options.strongMode,
55 'showPackageWarnings': options.showPackageWarnings, 57 'showPackageWarnings': options.showPackageWarnings,
58 'showPackageWarningsPrefix': options.showPackageWarningsPrefix,
56 'showSdkWarnings': options.showSdkWarnings, 59 'showSdkWarnings': options.showSdkWarnings,
57 'definedVariables': options.definedVariables, 60 'definedVariables': options.definedVariables,
58 'packageRootPath': options.packageRootPath, 61 'packageRootPath': options.packageRootPath,
59 'packageConfigPath': options.packageConfigPath, 62 'packageConfigPath': options.packageConfigPath,
60 'sourceFiles': options.sourceFiles, 63 'sourceFiles': options.sourceFiles,
61 }; 64 };
62 65
63 // Convert performance tags to JSON representation. 66 // Convert performance tags to JSON representation.
64 var perfTagsJson = <String, dynamic>{}; 67 var perfTagsJson = <String, dynamic>{};
65 for (PerformanceTag tag in PerformanceTag.all) { 68 for (PerformanceTag tag in PerformanceTag.all) {
(...skipping 16 matching lines...) Expand all
82 taskRows.add(new _TaskRow(key.toString(), time, count)); 85 taskRows.add(new _TaskRow(key.toString(), time, count));
83 } 86 }
84 taskRows.sort((a, b) => b.time.compareTo(a.time)); 87 taskRows.sort((a, b) => b.time.compareTo(a.time));
85 88
86 var reportJson = <String, dynamic>{ 89 var reportJson = <String, dynamic>{
87 'perfReportVersion': 0, 90 'perfReportVersion': 0,
88 'platform': platformJson, 91 'platform': platformJson,
89 'options': optionsJson, 92 'options': optionsJson,
90 'totalElapsedTime': totalTime, 93 'totalElapsedTime': totalTime,
91 'totalTaskTime': totalTaskTime, 94 'totalTaskTime': totalTaskTime,
95 'analyzedFiles': analyzedFileCount,
96 'generatedDiagnostics': stats.unfilteredCount,
97 'reportedDiagnostics': stats.filteredCount,
92 'performanceTags': perfTagsJson, 98 'performanceTags': perfTagsJson,
93 'tasks': taskRows.map((r) => r.toJson()).toList(), 99 'tasks': taskRows.map((r) => r.toJson()).toList(),
94 }; 100 };
95 101
96 return _JSON.convert(reportJson); 102 return _JSON.convert(reportJson);
97 } 103 }
98 104
99 class _TaskRow { 105 class _TaskRow {
100 final String name; 106 final String name;
101 final int time; 107 final int time;
102 final int count; 108 final int count;
103 _TaskRow(this.name, this.time, this.count); 109 _TaskRow(this.name, this.time, this.count);
104 110
105 Map toJson() => <String, dynamic>{'name': name, 'time': time, 'count': count}; 111 Map toJson() => <String, dynamic>{'name': name, 'time': time, 'count': count};
106 } 112 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/options.dart ('k') | pkg/analyzer_cli/test/all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698