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

Unified Diff: pkg/analyzer_cli/lib/src/perf_report.dart

Issue 1524413002: Add --x-perf-report flag to the dartanalyzer command (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add a test Created 5 years 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/perf_report.dart
diff --git a/pkg/analyzer_cli/lib/src/perf_report.dart b/pkg/analyzer_cli/lib/src/perf_report.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1b8164e740b962101f446f52f06e252b85791acd
--- /dev/null
+++ b/pkg/analyzer_cli/lib/src/perf_report.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2015, 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 analyzer_cli.src.perf_report;
+
+import 'dart:convert' show JsonEncoder;
+import 'dart:io' show File, Platform;
+
+import 'package:analyzer/src/generated/utilities_general.dart'
+ show PerformanceTag;
+import 'package:analyzer_cli/src/options.dart' show CommandLineOptions;
+
+const _JSON = const JsonEncoder.withIndent(" ");
+
+String makePerfReport(int startTime, int endTime, CommandLineOptions options) {
Brian Wilkerson 2015/12/17 15:05:41 We should add a version number to the output so th
+ int totalTime = endTime - startTime;
+ int otherTime = totalTime;
+
+ var platformJson = <String, dynamic>{
+ 'osType': _osType,
+ 'dartSdkVersion': Platform.version,
+ 'checkedMode': _isCheckedMode,
+ };
+
+ var optionsJson = <String, dynamic>{
+ 'dartSdkPath': options.dartSdkPath,
+ 'strongMode': options.strongMode,
+ 'showPackageWarnings': options.showPackageWarnings,
+ 'showSdkWarnings': options.showSdkWarnings,
+ 'definedVariables': options.definedVariables,
+ 'packageRootPath': options.packageRootPath,
+ 'packageConfigPath': options.packageConfigPath,
+ 'sourceFiles': options.sourceFiles,
+ };
+
+ // Convert performance tags to JSON representation.
+ var perfTagsJson = <String, dynamic>{};
+ for (PerformanceTag tag in PerformanceTag.all) {
+ if (tag != PerformanceTag.UNKNOWN) {
+ int tagTime = tag.elapsedMs;
+ perfTagsJson[tag.label] = tagTime;
+ otherTime -= tagTime;
+ }
+ }
+ perfTagsJson['other'] = otherTime;
+
+ var json = <String, dynamic>{
+ 'platform': platformJson,
+ 'options': optionsJson,
+ 'totalElapsedTime': totalTime,
+ 'performanceTags': perfTagsJson
+ };
+
+ return _JSON.convert(json);
+}
+
+bool _isCheckedMode = () {
+ bool x = true;
+ try {
+ // Trigger an exception if we're in checked mode.
+ x = "" as dynamic;
+ return x != ""; // return false; suppress unused variable warning
+ } catch (e) {
+ return true;
+ }
+}();
+
+String _osType = () {
+ if (Platform.isLinux) {
+ return "linux";
+ } else if (Platform.isMacOS) {
+ return "mac";
+ } else if (Platform.isWindows) {
+ return "windows";
+ } else if (Platform.isAndroid) {
+ return "android";
+ } else {
+ return "unknown";
+ }
+}();
« 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