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

Side by Side 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 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyzer_cli.src.perf_report;
6
7 import 'dart:convert' show JsonEncoder;
8 import 'dart:io' show File, Platform;
9
10 import 'package:analyzer/src/generated/utilities_general.dart'
11 show PerformanceTag;
12 import 'package:analyzer_cli/src/options.dart' show CommandLineOptions;
13
14 const _JSON = const JsonEncoder.withIndent(" ");
15
16 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
17 int totalTime = endTime - startTime;
18 int otherTime = totalTime;
19
20 var platformJson = <String, dynamic>{
21 'osType': _osType,
22 'dartSdkVersion': Platform.version,
23 'checkedMode': _isCheckedMode,
24 };
25
26 var optionsJson = <String, dynamic>{
27 'dartSdkPath': options.dartSdkPath,
28 'strongMode': options.strongMode,
29 'showPackageWarnings': options.showPackageWarnings,
30 'showSdkWarnings': options.showSdkWarnings,
31 'definedVariables': options.definedVariables,
32 'packageRootPath': options.packageRootPath,
33 'packageConfigPath': options.packageConfigPath,
34 'sourceFiles': options.sourceFiles,
35 };
36
37 // Convert performance tags to JSON representation.
38 var perfTagsJson = <String, dynamic>{};
39 for (PerformanceTag tag in PerformanceTag.all) {
40 if (tag != PerformanceTag.UNKNOWN) {
41 int tagTime = tag.elapsedMs;
42 perfTagsJson[tag.label] = tagTime;
43 otherTime -= tagTime;
44 }
45 }
46 perfTagsJson['other'] = otherTime;
47
48 var json = <String, dynamic>{
49 'platform': platformJson,
50 'options': optionsJson,
51 'totalElapsedTime': totalTime,
52 'performanceTags': perfTagsJson
53 };
54
55 return _JSON.convert(json);
56 }
57
58 bool _isCheckedMode = () {
59 bool x = true;
60 try {
61 // Trigger an exception if we're in checked mode.
62 x = "" as dynamic;
63 return x != ""; // return false; suppress unused variable warning
64 } catch (e) {
65 return true;
66 }
67 }();
68
69 String _osType = () {
70 if (Platform.isLinux) {
71 return "linux";
72 } else if (Platform.isMacOS) {
73 return "mac";
74 } else if (Platform.isWindows) {
75 return "windows";
76 } else if (Platform.isAndroid) {
77 return "android";
78 } else {
79 return "unknown";
80 }
81 }();
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