-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add a new package: measure #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d34d5ad
92e44b3
76b5189
d60482e
299363a
cb9736e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package: flutter/packages/measure/resources | ||
| description: Binaries and other resources for measuring performance metrics. | ||
| install_mode: copy | ||
| data: | ||
| - dir: resources |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,15 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:args/command_runner.dart'; | ||
| import 'package:meta/meta.dart'; | ||
|
|
||
| const String kOptionResourcesRoot = 'resources-root'; | ||
| const String kOptionTimeLimitMs = 'time-limit-ms'; | ||
| const String kOptionTemplate = 'template'; | ||
| const String kOptionDevice = 'device'; | ||
| const String kOptionProessName = 'process-name'; | ||
| const String kOptionTraceUtility = 'trace-utility'; | ||
| const String kOptionOutJson = 'out-json'; | ||
| const String kFlagVerbose = 'verbose'; | ||
|
|
||
|
|
@@ -21,9 +22,57 @@ abstract class BaseCommand extends Command<void> { | |
| argParser.addOption( | ||
| kOptionOutJson, | ||
| abbr: 'o', | ||
| help: 'json file for the measure result.', | ||
| help: 'Specifies the json file for outputing result.', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| defaultsTo: 'result.json', | ||
| ); | ||
| argParser.addOption( | ||
| kOptionResourcesRoot, | ||
| abbr: 'r', | ||
| help: 'Specifies the path to download resources', | ||
| defaultsTo: defaultResourcesRoot, | ||
| ); | ||
| } | ||
|
|
||
| static String get defaultResourcesRoot => | ||
| '${Platform.environment['HOME']}/.measure'; | ||
|
|
||
| static Future<void> doEnsureResources( | ||
| String rootPath, | ||
| {bool isVerbose}) async | ||
| { | ||
| final Directory root = | ||
| await Directory(rootPath).create(recursive: true); | ||
| final Directory previous = Directory.current; | ||
| Directory.current = root; | ||
| final File ensureFile = File('ensure_file.txt'); | ||
| ensureFile.writeAsStringSync('flutter/packages/measure/resources latest'); | ||
| if (isVerbose) { | ||
| print('Downloading resources from CIPD...'); | ||
| } | ||
| final ProcessResult result = Process.runSync( | ||
| 'cipd', | ||
| <String>[ | ||
| 'ensure', | ||
| '-ensure-file', | ||
| 'ensure_file.txt', | ||
| '-root', | ||
| '.', | ||
| ], | ||
| ); | ||
| if (result.exitCode != 0) { | ||
| print('cipd ensure stdout:\n${result.stdout}\n'); | ||
| print('cipd ensure stderr:\n${result.stderr}\n'); | ||
| throw Exception('Failed to download the CIPD package.'); | ||
| } | ||
| if (isVerbose) { | ||
| print('Download completes.'); | ||
| } | ||
| Directory.current = previous; | ||
| } | ||
|
|
||
| @protected | ||
| Future<void> ensureResources() async { | ||
| doEnsureResources(resourcesRoot, isVerbose: isVerbose); | ||
| } | ||
|
|
||
| @protected | ||
|
|
@@ -37,17 +86,12 @@ abstract class BaseCommand extends Command<void> { | |
| bool get isVerbose => argResults[kFlagVerbose]; | ||
| @protected | ||
| String get outJson => argResults[kOptionOutJson]; | ||
| @protected | ||
| String get resourcesRoot => argResults[kOptionResourcesRoot]; | ||
| } | ||
|
|
||
| abstract class IosCpuGpuSubcommand extends BaseCommand { | ||
| IosCpuGpuSubcommand() { | ||
| argParser.addOption( | ||
| kOptionTraceUtility, | ||
| abbr: 'u', | ||
| help: | ||
| 'Specifies path to TraceUtility binary ' | ||
| '(https://github.com/Qusic/TraceUtility).', | ||
| ); | ||
| argParser.addOption( | ||
| kOptionProessName, | ||
| abbr: 'p', | ||
|
|
@@ -58,8 +102,8 @@ abstract class IosCpuGpuSubcommand extends BaseCommand { | |
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| } | ||
|
|
||
| @protected | ||
| String get traceUtility => argResults[kOptionTraceUtility]; | ||
| @protected | ||
| String get processName => argResults[kOptionProessName]; | ||
| @protected | ||
| String get traceUtilityPath => '$resourcesRoot/resources/TraceUtility'; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a section explaining what this packages does / what it is for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.