Unverified Commit b81e3611 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Revert "Refactor analysis benchmark and collect more data" (#20280)

* Revert "increase size of user account drawer headers to 48 by 48 (#20266)"

This reverts commit 4a7b4a4d.

* Revert "EditableText Cursor can be set to not blink for testing (#20004)"

This reverts commit d041b319.

* Revert "Refactor analysis benchmark and collect more data (#20169)"

This reverts commit 5ea0a135.
parent 4a7b4a4d
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:math' as math;
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../framework/framework.dart'; import '../framework/framework.dart';
import '../framework/utils.dart'; import '../framework/utils.dart';
/// Run each benchmark this many times and compute average, min, max. /// Run each benchmark this many times and compute average.
///
/// This must be small enough that we can do all the work in 15 minutes, the
/// devicelab deadline. Since there's four different analysis tasks, on average,
/// each can have 4 minutes. The tasks currently average a little more than a
/// minute, so that allows three runs per task.
const int _kRunsPerBenchmark = 3; const int _kRunsPerBenchmark = 3;
/// Runs a benchmark once and reports the result as a lower-is-better numeric
/// value.
typedef Future<double> _Benchmark();
/// Path to the generated "mega gallery" app. /// Path to the generated "mega gallery" app.
Directory get _megaGalleryDirectory => dir(path.join(Directory.systemTemp.path, 'mega_gallery')); Directory get _megaGalleryDirectory => dir(path.join(Directory.systemTemp.path, 'mega_gallery'));
...@@ -28,101 +28,76 @@ Future<TaskResult> analyzerBenchmarkTask() async { ...@@ -28,101 +28,76 @@ Future<TaskResult> analyzerBenchmarkTask() async {
await dart(<String>['dev/tools/mega_gallery.dart', '--out=${_megaGalleryDirectory.path}']); await dart(<String>['dev/tools/mega_gallery.dart', '--out=${_megaGalleryDirectory.path}']);
}); });
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{
data.addAll((await _run(new _FlutterRepoBenchmark())).asMap('flutter_repo', 'batch')); 'flutter_repo_batch': await _run(new _FlutterRepoBenchmark()),
data.addAll((await _run(new _FlutterRepoBenchmark(watch: true))).asMap('flutter_repo', 'watch')); 'flutter_repo_watch': await _run(new _FlutterRepoBenchmark(watch: true)),
data.addAll((await _run(new _MegaGalleryBenchmark())).asMap('mega_gallery', 'batch')); 'mega_gallery_batch': await _run(new _MegaGalleryBenchmark()),
data.addAll((await _run(new _MegaGalleryBenchmark(watch: true))).asMap('mega_gallery', 'watch')); 'mega_gallery_watch': await _run(new _MegaGalleryBenchmark(watch: true)),
};
return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
} }
class _BenchmarkResult { /// Times how long it takes to analyze the Flutter repository.
const _BenchmarkResult(this.mean, this.min, this.max); class _FlutterRepoBenchmark {
_FlutterRepoBenchmark({ this.watch = false });
final double mean; // seconds final bool watch;
final double min; // seconds Future<double> call() async {
section('Analyze Flutter repo ${watch ? 'with watcher' : ''}');
final Stopwatch stopwatch = new Stopwatch();
await inDirectory(flutterDirectory, () async {
final List<String> options = <String>[
'--flutter-repo',
'--benchmark',
];
final double max; // seconds if (watch)
options.add('--watch');
Map<String, dynamic> asMap(String benchmark, String mode) { stopwatch.start();
return <String, dynamic>{ await flutter('analyze', options: options);
'${benchmark}_$mode': mean, stopwatch.stop();
'${benchmark}_${mode}_minimum': min, });
'${benchmark}_${mode}_maximum': max, return stopwatch.elapsedMilliseconds / 1000;
};
} }
} }
abstract class _Benchmark { /// Times how long it takes to analyze the generated "mega_gallery" app.
_Benchmark({ this.watch = false }); class _MegaGalleryBenchmark {
_MegaGalleryBenchmark({ this.watch = false });
final bool watch; final bool watch;
String get title; Future<double> call() async {
section('Analyze mega gallery ${watch ? 'with watcher' : ''}');
Directory get directory; final Stopwatch stopwatch = new Stopwatch();
await inDirectory(_megaGalleryDirectory, () async {
final List<String> options = <String>[
'--benchmark',
];
List<String> get options { if (watch)
final List<String> result = <String>[ '--benchmark' ]; options.add('--watch');
if (watch)
options.add('--watch');
return result;
}
Future<double> execute(int iteration, int targetIterations) async {
section('Analyze $title ${watch ? 'with watcher' : ''} - ${iteration + 1} / $targetIterations');
final Stopwatch stopwatch = new Stopwatch();
await inDirectory(directory, () async {
stopwatch.start(); stopwatch.start();
await flutter('analyze', options: options); await flutter('analyze', options: options);
stopwatch.stop(); stopwatch.stop();
}); });
return stopwatch.elapsedMicroseconds / (1000.0 * 1000.0); return stopwatch.elapsedMilliseconds / 1000;
} }
} }
/// Times how long it takes to analyze the Flutter repository. /// Runs a [benchmark] several times and reports the average result.
class _FlutterRepoBenchmark extends _Benchmark { Future<double> _run(_Benchmark benchmark) async {
_FlutterRepoBenchmark({ bool watch = false }) : super(watch: watch); double best;
for (int i = 0; i < _kRunsPerBenchmark; i++) {
@override
String get title => 'Flutter repo';
@override
Directory get directory => flutterDirectory;
@override
List<String> get options {
return super.options
..add('--flutter-repo');
}
}
/// Times how long it takes to analyze the generated "mega_gallery" app.
class _MegaGalleryBenchmark extends _Benchmark {
_MegaGalleryBenchmark({ bool watch = false }) : super(watch: watch);
@override
String get title => 'mega gallery';
@override
Directory get directory => _megaGalleryDirectory;
}
/// Runs `benchmark` several times and reports the results.
Future<_BenchmarkResult> _run(_Benchmark benchmark) async {
final List<double> results = <double>[];
for (int i = 0; i < _kRunsPerBenchmark; i += 1) {
// Delete cached analysis results. // Delete cached analysis results.
rmTree(dir('${Platform.environment['HOME']}/.dartServer')); rmTree(dir('${Platform.environment['HOME']}/.dartServer'));
results.add(await benchmark.execute(i, _kRunsPerBenchmark));
final double result = await benchmark();
best = math.min(result, best ?? result);
} }
results.sort(); return best;
final double sum = results.fold<double>(
0.0,
(double previousValue, double element) => previousValue + element,
);
return new _BenchmarkResult(sum / results.length, results.first, results.last);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment