Skip to content

Commit

Permalink
Rename measure to gauge (flutter#34)
Browse files Browse the repository at this point in the history
Because the name "measure" has already been taken in pub.
  • Loading branch information
liyuqian authored Sep 16, 2019
1 parent db15561 commit a533c61
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

8 changes: 8 additions & 0 deletions packages/gauge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 0.1.1

* Improve tests and remove unnecessary resources.

## 0.1.0

* Initial release.

File renamed without changes.
14 changes: 7 additions & 7 deletions packages/measure/README.md → packages/gauge/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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:
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/measure/cipd.yaml → packages/gauge/cipd.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions packages/measure/pubspec.yaml → packages/gauge/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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
Expand Down
40 changes: 40 additions & 0 deletions packages/gauge/test/gauge_general_test.dart
Original file line number Diff line number Diff line change
@@ -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>'),
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 0 additions & 4 deletions packages/measure/CHANGELOG.md

This file was deleted.

0 comments on commit a533c61

Please sign in to comment.