Rename measure to gauge (#34)

Because the name "measure" has already been taken in pub.
This commit is contained in:
liyuqian
2019-09-16 11:38:50 -07:00
committed by GitHub
parent db155615d1
commit a533c61c47
15 changed files with 83 additions and 52 deletions

4
.gitignore vendored
View File

@ -14,8 +14,8 @@ GeneratedPluginRegistrant.m
GeneratedPluginRegistrant.java
packages/measure/result.json
packages/measure/resources
packages/gauge/result.json
packages/gauge/resources
*instrumentscli*.trace
*.cipd

View File

@ -0,0 +1,8 @@
## 0.1.1
* Improve tests and remove unnecessary resources.
## 0.1.0
* Initial release.

View File

@ -1,4 +1,4 @@
Tools for measuring some performance metrics.
Tools for gauging/measuring some performance metrics.
Currently there's only one tool to measure iOS CPU/GPU usages for Flutter's CI
tests.
@ -12,13 +12,13 @@ your path.
Finally run:
```shell
pub global activate measure
pub global activate gauge
```
# Run
Connect an iPhone, run a Flutter app on it, and
```shell
measure ioscpugpu new
gauge ioscpugpu new
```
Sample output:
@ -28,10 +28,10 @@ gpu: 12.4%, cpu: 22.525%
For more information, try
```shell
measure help
measure help ioscpugpu
measure help ioscpugpu new
measure help ioscpugpu parse
gauge help
gauge help ioscpugpu
gauge help ioscpugpu new
gauge help ioscpugpu parse
```
[1]: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up

View File

@ -4,12 +4,12 @@
import 'package:args/command_runner.dart';
import 'package:measure/commands/ioscpugpu.dart';
import 'package:gauge/commands/ioscpugpu.dart';
void main(List<String> args) {
final CommandRunner<void> runner = CommandRunner<void>(
'measure',
'Tools for measuring some performance metrics.',
'gauge',
'Tools for gauging/measuring some performance metrics.',
);
runner.addCommand(IosCpuGpu());
runner.run(args);

View File

@ -1,4 +1,4 @@
package: flutter/packages/measure/resources
package: flutter/packages/gauge/resources
description: Binaries and other resources for measuring performance metrics.
install_mode: copy
data:

View File

@ -34,15 +34,15 @@ abstract class BaseCommand extends Command<void> {
}
static String get defaultResourcesRoot =>
'${Platform.environment['HOME']}/.measure';
'${Platform.environment['HOME']}/.gauge';
static Future<void> doEnsureResources(String rootPath,
{bool isVerbose}) async {
{bool isVerbose = false}) 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');
ensureFile.writeAsStringSync('flutter/packages/gauge/resources latest');
if (isVerbose) {
print('Downloading resources from CIPD...');
}

View File

@ -3,8 +3,8 @@
// found in the LICENSE file.
import 'package:args/command_runner.dart';
import 'package:measure/commands/ioscpugpu/new.dart';
import 'package:measure/commands/ioscpugpu/parse.dart';
import 'package:gauge/commands/ioscpugpu/new.dart';
import 'package:gauge/commands/ioscpugpu/parse.dart';
class IosCpuGpu extends Command<void> {
IosCpuGpu() {

View File

@ -5,8 +5,8 @@
import 'dart:async';
import 'dart:io';
import 'package:measure/commands/base.dart';
import 'package:measure/parser.dart';
import 'package:gauge/commands/base.dart';
import 'package:gauge/parser.dart';
class IosCpuGpuNew extends IosCpuGpuSubcommand {
IosCpuGpuNew() {

View File

@ -4,22 +4,21 @@
import 'dart:async';
import 'package:measure/commands/base.dart';
import 'package:measure/parser.dart';
import 'package:gauge/commands/base.dart';
import 'package:gauge/parser.dart';
class IosCpuGpuParse extends IosCpuGpuSubcommand {
@override
String get name => 'parse';
@override
String get description =>
'parse an existing instruments trace with CPU/GPU measurements.';
'Parse an existing instruments trace with CPU/GPU measurements.';
@override
String get usage {
final List<String> lines = super.usage.split('\n');
lines[0] = 'Usage: measure ioscpugpu -u <trace-utility-path> '
'parse <trace-file-path>';
return lines.join('\n');
return super.usage.split('\n').map((String line) {
return line + (line.startsWith('Usage:') ? ' <trace-file-path>' : '');
}).join('\n');
}
@override

View File

@ -1,11 +1,11 @@
name: measure
description: Tools for measuring some performance metrics.
name: gauge
description: Tools for gauging/measuring some performance metrics.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/packages/tree/master/packages/measure
version: 0.1.0
homepage: https://github.com/flutter/packages/tree/master/packages/gauge
version: 0.1.1
executables:
measure: measure
gauge: gauge
dependencies:
args: ^1.5.2

View File

@ -0,0 +1,40 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// 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:test/test.dart';
void main() {
final String gaugeRootPath = Directory.current.absolute.path;
test('help works', () {
final ProcessResult result = Process.runSync(
'dart',
<String>['$gaugeRootPath/bin/gauge.dart', 'help'],
);
expect(
result.stdout.toString(),
contains(
'Tools for gauging/measuring some performance metrics.',
));
});
test('ioscpugpu parse help works', () {
final ProcessResult result = Process.runSync(
'dart',
<String>['$gaugeRootPath/bin/gauge.dart', 'ioscpugpu', 'parse'],
);
final String help = result.stdout.toString();
expect(
help.split('\n')[0],
equals('Parse an existing instruments trace with CPU/GPU measurements.'),
);
expect(
help,
contains('Usage: gauge ioscpugpu parse [arguments] <trace-file-path>'),
);
});
}

View File

@ -8,30 +8,18 @@ import 'dart:io';
import 'package:test/test.dart';
import 'package:measure/commands/base.dart';
import 'package:gauge/commands/base.dart';
void main() {
const String measureRootPath = '.';
final String gaugeRootPath = Directory.current.absolute.path;
final String resourcesRootPath = BaseCommand.defaultResourcesRoot;
BaseCommand.doEnsureResources(resourcesRootPath, isVerbose: true);
test('help works', () {
final ProcessResult result = Process.runSync(
'dart',
<String>['$measureRootPath/bin/measure.dart', 'help'],
);
expect(
result.stdout.toString(),
contains(
'Tools for measuring some performance metrics.',
));
});
BaseCommand.doEnsureResources(resourcesRootPath);
ProcessResult _testIosCpuGpu(List<String> extraArgs) {
return Process.runSync(
'dart',
<String>[
'$measureRootPath/bin/measure.dart',
'$gaugeRootPath/bin/gauge.dart',
'ioscpugpu',
...extraArgs,
'-r',

View File

@ -1,4 +0,0 @@
## 0.1.0
* Initial release.