Skip to content

Commit

Permalink
Reverts "Run all microbenchmarks (flutter#154374)" (flutter#154440)
Browse files Browse the repository at this point in the history
Reverts: flutter#154374
Initiated by: jtmcdole
Reason for reverting: A different benchmark was using the microbenchmark parser and timing out.
Original PR Author: jtmcdole

Reviewed By: {zanderso}

This change reverts the following previous change:
Two things:

**Re-land**: Uninstall microbenchmarks before running them.
Flakes in flutter#153828 stem from adb saying the app isn't installed, but then failing to install wtih `-r`. Several other tests uninstall the app before trying to run it. Previous fix called uninstall between tests, but iOS takes 12 to 13 seconds to perform uninstall / install, which timed out the test.  Just uninstall the one time since we only care about any lingering apps with different keys.
Potential solution flutter#153828

**Make things go fast**
Instead of installing 21 different compilations of the same app to get results; compile and run them together. Locally on Mac+iOS, this should takes ~3 minutes instead of ~15 minutes.
  • Loading branch information
auto-submit[bot] authored and Buchimi committed Sep 2, 2024
1 parent 6608558 commit e47b859
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 201 deletions.
17 changes: 11 additions & 6 deletions dev/benchmarks/microbenchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# microbenchmarks

To run these benchmarks on a device, first run `flutter logs` in one
window to see the device logs, then, in a different window, run:
To run these benchmarks on a device, first run `flutter logs' in one
window to see the device logs, then, in a different window, run any of
these:

```sh
flutter run -d $DEVICE_ID --profile lib/benchmark_collection.dart
flutter run --release lib/gestures/velocity_tracker_bench.dart
flutter run --release lib/gestures/gesture_detector_bench.dart
flutter run --release lib/stocks/animation_bench.dart
flutter run --release lib/stocks/build_bench.dart
flutter run --release lib/stocks/layout_bench.dart
```

The results should be in the device logs.

## Avoid changing names of the benchmarks
### Avoid changing names of the benchmarks

Each microbenchmark is identified by a name, for example,
"catmullrom_transform_iteration". Changing the name passed to `BenchmarkResultPrinter.addResult`
will effectively remove the old benchmark and create a new one,
"catmullrom_transform_iteration". Changing the name of an existing
microbenchmarks will effectively remove the old benchmark and create a new one,
losing the historical data associated with the old benchmark in the process.
23 changes: 0 additions & 23 deletions dev/benchmarks/microbenchmarks/lib/benchmark_binding.dart

This file was deleted.

107 changes: 0 additions & 107 deletions dev/benchmarks/microbenchmarks/lib/benchmark_collection.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import '../common.dart';

const int _kNumIters = 10000;

Future<void> execute() async {
Future<void> main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
runApp(MaterialApp(
home: Scaffold(
body: GridView.count(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const int _kNumIterations = 65536;
const int _kNumWarmUp = 100;
const int _kScale = 1000;

Future<void> execute() async {
void main() {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");

// In the following benchmarks, we won't remove the listeners when we don't
Expand Down
2 changes: 1 addition & 1 deletion dev/benchmarks/microbenchmarks/lib/foundation/clamp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../common.dart';
const int _kBatchSize = 100000;
const int _kNumIterations = 1000;

Future<void> execute() async {
void main() {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../common.dart';

const int _kNumIterations = 1000;

Future<void> execute() async {
void main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");

final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../common.dart';
const int _kBatchSize = 100;
const int _kNumIterations = 100;

Future<void> execute() async {
void main() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../common.dart';

const int _kNumIterations = 100000;

Future<void> execute() async {
void main() {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../common.dart';

const int _kNumIterations = 100000;

Future<void> execute() async {
void main() {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../common.dart';

const int _kNumIterations = 10000;

Future<void> execute() async {
void main() {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import '../common.dart';
const int _kNumIterations = 10000000;
const int _kNumWarmUp = 100000;

Future<void> execute() async {
void main() {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
print('MatrixUtils.transformRect and .transformPoint benchmark...');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../common.dart';

const int _kNumIters = 10000;

Future<void> execute() async {
void main() {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final Stopwatch watch = Stopwatch();
print('RRect contains benchmark...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'apps/button_matrix_app.dart' as button_matrix;
const int _kNumWarmUpIters = 20;
const int _kNumIters = 300;

Future<void> execute() async {
Future<void> main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final Stopwatch watch = Stopwatch();
print('GestureDetector semantics benchmark...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TrackerBenchmark {
final String name;
}

Future<void> execute() async {
Future<void> main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
final List<TrackerBenchmark> benchmarks = <TrackerBenchmark>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ List<Data> test(int length) {
(int index) => Data(index * index));
}

Future<void> execute() async {
Future<void> main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");

// Warm up lap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../common.dart';
const int _kNumIterations = 1000;
const int _kNumWarmUp = 100;

Future<void> execute() async {
void main() {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");

// Warm up lap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../common.dart';
const int _kNumIterations = 1000;
const int _kNumWarmUp = 100;

Future<void> execute() async {
void main() {
final List<String> words = 'Lorem Ipsum is simply dummy text of the printing and'
" typesetting industry. Lorem Ipsum has been the industry's"
' standard dummy text ever since the 1500s, when an unknown'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final Widget intrinsicTextHeight = Directionality(
),
);

Future<void> execute() async {
Future<void> main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");

// We control the framePolicy below to prevent us from scheduling frames in
Expand Down
33 changes: 26 additions & 7 deletions dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,35 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:stocks/main.dart' as stocks;
import 'package:stocks/stock_data.dart' as stock_data;

import '../benchmark_binding.dart';
import '../common.dart';

const Duration kBenchmarkTime = Duration(seconds: 15);

Future<void> execute(BenchmarkingBinding binding) async {
class BenchmarkingBinding extends LiveTestWidgetsFlutterBinding {
BenchmarkingBinding(this.stopwatch);

final Stopwatch stopwatch;

@override
void handleBeginFrame(Duration? rawTimeStamp) {
stopwatch.start();
super.handleBeginFrame(rawTimeStamp);
}

@override
void handleDrawFrame() {
super.handleDrawFrame();
stopwatch.stop();
}
}

Future<void> main() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
stock_data.StockData.actuallyFetchData = false;

final Stopwatch wallClockWatch = Stopwatch();
final Stopwatch cpuWatch = Stopwatch();
BenchmarkingBinding(cpuWatch);

int totalOpenFrameElapsedMicroseconds = 0;
int totalOpenIterationCount = 0;
Expand All @@ -33,27 +52,27 @@ Future<void> execute(BenchmarkingBinding binding) async {
bool drawerIsOpen = false;
wallClockWatch.start();
while (wallClockWatch.elapsed < kBenchmarkTime) {
binding.drawFrameWatch.reset();
cpuWatch.reset();
if (drawerIsOpen) {
await tester.tapAt(const Offset(780.0, 250.0)); // Close drawer
await tester.pump();
totalCloseIterationCount += 1;
totalCloseFrameElapsedMicroseconds += binding.drawFrameWatch.elapsedMicroseconds;
totalCloseFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
} else {
await tester.tapAt(const Offset(20.0, 50.0)); // Open drawer
await tester.pump();
totalOpenIterationCount += 1;
totalOpenFrameElapsedMicroseconds += binding.drawFrameWatch.elapsedMicroseconds;
totalOpenFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
}
drawerIsOpen = !drawerIsOpen;

// Time how long each frame takes
binding.drawFrameWatch.reset();
cpuWatch.reset();
while (SchedulerBinding.instance.hasScheduledFrame) {
await tester.pump();
totalSubsequentFramesIterationCount += 1;
}
totalSubsequentFramesElapsedMicroseconds += binding.drawFrameWatch.elapsedMicroseconds;
totalSubsequentFramesElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
}
});

Expand Down
2 changes: 1 addition & 1 deletion dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Future<List<double>> runBuildBenchmark() async {
return values;
}

Future<void> execute() async {
Future<void> main() async {
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
printer.addResultStatistics(
description: 'Stock build',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../common.dart';
import 'build_bench.dart';

Future<void> execute() async {
Future<void> main() async {
debugProfileBuildsEnabledUserWidgets = true;
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
printer.addResultStatistics(
Expand Down
Loading

0 comments on commit e47b859

Please sign in to comment.