Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -14,17 +14,13 @@ import 'benchmark_binding.dart';
import 'foundation/all_elements_bench.dart' as all_elements_bench;
import 'foundation/change_notifier_bench.dart' as change_notifier_bench;
import 'foundation/clamp.dart' as clamp;
import 'foundation/decode_and_parse_asset_manifest.dart'
as decode_and_parse_asset_manifest;
import 'foundation/decode_and_parse_asset_manifest.dart' as decode_and_parse_asset_manifest;
import 'foundation/observer_list_bench.dart' as observer_list_bench;
import 'foundation/platform_asset_bundle.dart' as platform_asset_bundle;
import 'foundation/standard_message_codec_bench.dart'
as standard_message_codec_bench;
import 'foundation/standard_method_codec_bench.dart'
as standard_method_codec_bench;
import 'foundation/standard_message_codec_bench.dart' as standard_message_codec_bench;
import 'foundation/standard_method_codec_bench.dart' as standard_method_codec_bench;
import 'foundation/timeline_bench.dart' as timeline_bench;
import 'geometry/matrix_utils_transform_bench.dart'
as matrix_utils_transform_bench;
import 'geometry/matrix_utils_transform_bench.dart' as matrix_utils_transform_bench;
import 'geometry/rrect_contains_bench.dart' as rrect_contains_bench;
import 'gestures/gesture_detector_bench.dart' as gesture_detector_bench;
import 'gestures/velocity_tracker_bench.dart' as velocity_tracker_bench;
@@ -41,8 +37,7 @@ import 'ui/image_bench.dart' as image_bench;
typedef Benchmark = (String name, Future<void> Function() value);
Future<void> main() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
// BenchmarkingBinding is used by animation_bench, providing a simple
// stopwatch interface over rendering. Lifting it here makes all
@@ -52,33 +47,18 @@ Future<void> main() async {
('foundation/change_notifier_bench.dart', change_notifier_bench.execute),
('foundation/clamp.dart', clamp.execute),
('foundation/platform_asset_bundle.dart', platform_asset_bundle.execute),
(
'foundation/standard_message_codec_bench.dart',
standard_message_codec_bench.execute
),
(
'foundation/standard_method_codec_bench.dart',
standard_method_codec_bench.execute
),
('foundation/standard_message_codec_bench.dart', standard_message_codec_bench.execute),
('foundation/standard_method_codec_bench.dart', standard_method_codec_bench.execute),
('foundation/timeline_bench.dart', timeline_bench.execute),
(
'foundation/decode_and_parse_asset_manifest.dart',
decode_and_parse_asset_manifest.execute
),
('foundation/decode_and_parse_asset_manifest.dart', decode_and_parse_asset_manifest.execute),
('foundation/observer_list_bench.dart', observer_list_bench.execute),
(
'geometry/matrix_utils_transform_bench.dart',
matrix_utils_transform_bench.execute
),
('geometry/matrix_utils_transform_bench.dart', matrix_utils_transform_bench.execute),
('geometry/rrect_contains_bench.dart', rrect_contains_bench.execute),
('gestures/gesture_detector_bench.dart', gesture_detector_bench.execute),
('gestures/velocity_tracker_bench.dart', velocity_tracker_bench.execute),
('language/compute_bench.dart', compute_bench.execute),
('language/sync_star_bench.dart', sync_star_bench.execute),
(
'language/sync_star_semantics_bench.dart',
sync_star_semantics_bench.execute
),
('language/sync_star_semantics_bench.dart', sync_star_semantics_bench.execute),
('stocks/animation_bench.dart', () => animation_bench.execute(binding)),
('stocks/build_bench.dart', build_bench.execute),
('stocks/build_bench_profiled.dart', build_bench_profiled.execute),
@@ -88,12 +68,11 @@ Future<void> main() async {
(
'foundation/all_elements_bench.dart',
() async {
binding.framePolicy =
LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
runApp(const SizedBox.shrink()); // ensure dispose
await SchedulerBinding.instance.endOfFrame;
await all_elements_bench.execute();
}
},
),
];
@@ -108,11 +87,7 @@ Future<void> main() async {
allowed: allowed,
help: 'selected tests to run',
);
parser.addOption(
'seed',
defaultsTo: '12345',
help: 'selects seed to sort tests by',
);
parser.addOption('seed', defaultsTo: '12345', help: 'selects seed to sort tests by');
final List<String> mainArgs = <String>[];
const String testArgs = String.fromEnvironment('tests');
if (testArgs.isNotEmpty) {
@@ -130,7 +105,8 @@ Future<void> main() async {
// Shuffle the tests because we don't want order dependent tests.
// It is the responsibility of the infra to tell us what the seed value is,
// in case we want to have the seed stable for some time period.
final List<Benchmark> tests = benchmarks.where((Benchmark e) => selectedTests.contains(e.$1)).toList();
final List<Benchmark> tests =
benchmarks.where((Benchmark e) => selectedTests.contains(e.$1)).toList();
tests.shuffle(Random(int.parse(results.option('seed')!)));
print('╡ ••• Running microbenchmarks ••• ╞');

View File

@@ -5,14 +5,12 @@
import 'dart:convert' show json;
import 'dart:math' as math;
double _doNormal(
{required double mean, required double stddev, required double x}) {
double _doNormal({required double mean, required double stddev, required double x}) {
return (1.0 / (stddev * math.sqrt(2.0 * math.pi))) *
math.pow(math.e, -0.5 * math.pow((x - mean) / stddev, 2.0));
}
double _doMean(List<double> values) =>
values.reduce((double x, double y) => x + y) / values.length;
double _doMean(List<double> values) => values.reduce((double x, double y) => x + y) / values.length;
double _doStddev(List<double> values, double mean) {
double stddev = 0.0;
@@ -64,7 +62,6 @@ double _doProbability({required double mean, required double stddev, required do
/// printer.printToStdout();
///
class BenchmarkResultPrinter {
final List<_BenchmarkResult> _results = <_BenchmarkResult>[];
/// Adds a benchmark result to the list of results.
@@ -73,7 +70,12 @@ class BenchmarkResultPrinter {
/// result value. [unit] is the unit of measurement, such as "ms", "km", "h".
/// [name] is a computer-readable name of the result used as a key in the JSON
/// serialization of the results.
void addResult({ required String description, required double value, required String unit, required String name }) {
void addResult({
required String description,
required double value,
required String unit,
required String name,
}) {
_results.add(_BenchmarkResult(description, value, unit, name));
}
@@ -95,8 +97,14 @@ class BenchmarkResultPrinter {
const double margin = 0.05;
final double probability = _doProbability(mean: mean, stddev: stddev, margin: margin);
_results.add(_BenchmarkResult(description, mean, unit, name));
_results.add(_BenchmarkResult('$description - probability margin of error $margin', probability,
'percent', '${name}_probability_5pct'));
_results.add(
_BenchmarkResult(
'$description - probability margin of error $margin',
probability,
'percent',
'${name}_probability_5pct',
),
);
}
/// Prints the results added via [addResult] to standard output, once as JSON

View File

@@ -12,35 +12,33 @@ import '../common.dart';
const int _kNumIters = 10000;
Future<void> execute() async {
runApp(MaterialApp(
home: Scaffold(
body: GridView.count(
crossAxisCount: 5,
children: List<Widget>.generate(25, (int index) {
return Center(
child: Scaffold(
appBar: AppBar(
title: Text('App $index'),
actions: const <Widget>[
Icon(Icons.help),
Icon(Icons.add),
Icon(Icons.ac_unit),
],
runApp(
MaterialApp(
home: Scaffold(
body: GridView.count(
crossAxisCount: 5,
children: List<Widget>.generate(25, (int index) {
return Center(
child: Scaffold(
appBar: AppBar(
title: Text('App $index'),
actions: const <Widget>[Icon(Icons.help), Icon(Icons.add), Icon(Icons.ac_unit)],
),
body: const Column(
children: <Widget>[
Text('Item 1'),
Text('Item 2'),
Text('Item 3'),
Text('Item 4'),
],
),
),
body: const Column(
children: <Widget>[
Text('Item 1'),
Text('Item 2'),
Text('Item 3'),
Text('Item 4'),
],
),
),
);
}),
);
}),
),
),
),
));
);
// Lists may not be scrolled into frame in landscape.
SystemChrome.setPreferredOrientations(<DeviceOrientation>[
@@ -57,19 +55,19 @@ Future<void> execute() async {
print('flutter_test allElements benchmark... (${WidgetsBinding.instance.rootElement})');
// Make sure we get enough elements to process for consistent benchmark runs
int elementCount = collectAllElementsFrom(WidgetsBinding.instance.rootElement!, skipOffstage: false).length;
int elementCount =
collectAllElementsFrom(WidgetsBinding.instance.rootElement!, skipOffstage: false).length;
while (elementCount < 2458) {
await Future<void>.delayed(Duration.zero);
elementCount = collectAllElementsFrom(WidgetsBinding.instance.rootElement!, skipOffstage: false).length;
elementCount =
collectAllElementsFrom(WidgetsBinding.instance.rootElement!, skipOffstage: false).length;
}
print('element count: $elementCount');
watch.start();
for (int i = 0; i < _kNumIters; i += 1) {
final List<Element> allElements = collectAllElementsFrom(
WidgetsBinding.instance.rootElement!,
skipOffstage: false,
).toList();
final List<Element> allElements =
collectAllElementsFrom(WidgetsBinding.instance.rootElement!, skipOffstage: false).toList();
allElements.clear();
}
watch.stop();

View File

@@ -79,25 +79,15 @@ Future<void> execute() async {
void runRemoveListenerBenchmark(int iteration, {bool addResult = true}) {
const String name = 'remove';
final List<VoidCallback> listeners = <VoidCallback>[
() {},
() {},
() {},
() {},
() {},
];
final List<VoidCallback> listeners = <VoidCallback>[() {}, () {}, () {}, () {}, () {}];
for (int listenerCount = 1; listenerCount <= 5; listenerCount += 1) {
final List<_Notifier> notifiers = List<_Notifier>.generate(
iteration,
(_) {
final _Notifier notifier = _Notifier();
for (int l = 0; l < listenerCount; l += 1) {
notifier.addListener(listeners[l]);
}
return notifier;
},
growable: false,
);
final List<_Notifier> notifiers = List<_Notifier>.generate(iteration, (_) {
final _Notifier notifier = _Notifier();
for (int l = 0; l < listenerCount; l += 1) {
notifier.addListener(listeners[l]);
}
return notifier;
}, growable: false);
final Stopwatch watch = Stopwatch();
watch.start();
@@ -120,36 +110,25 @@ Future<void> execute() async {
}
}
void runRemoveListenerWhileNotifyingBenchmark(int iteration,
{bool addResult = true}) {
void runRemoveListenerWhileNotifyingBenchmark(int iteration, {bool addResult = true}) {
const String name = 'removeWhileNotify';
final List<VoidCallback> listeners = <VoidCallback>[
() {},
() {},
() {},
() {},
() {},
];
final List<VoidCallback> listeners = <VoidCallback>[() {}, () {}, () {}, () {}, () {}];
for (int listenerCount = 1; listenerCount <= 5; listenerCount += 1) {
final List<_Notifier> notifiers = List<_Notifier>.generate(
iteration,
(_) {
final _Notifier notifier = _Notifier();
notifier.addListener(() {
// This listener will remove all other listeners. So that only this
// one is called and measured.
for (int l = 0; l < listenerCount; l += 1) {
notifier.removeListener(listeners[l]);
}
});
final List<_Notifier> notifiers = List<_Notifier>.generate(iteration, (_) {
final _Notifier notifier = _Notifier();
notifier.addListener(() {
// This listener will remove all other listeners. So that only this
// one is called and measured.
for (int l = 0; l < listenerCount; l += 1) {
notifier.addListener(listeners[l]);
notifier.removeListener(listeners[l]);
}
return notifier;
},
growable: false,
);
});
for (int l = 0; l < listenerCount; l += 1) {
notifier.addListener(listeners[l]);
}
return notifier;
}, growable: false);
final Stopwatch watch = Stopwatch();
watch.start();

View File

@@ -10,8 +10,7 @@ const int _kBatchSize = 100000;
const int _kNumIterations = 1000;
Future<void> execute() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
final Stopwatch watch = Stopwatch();

View File

@@ -20,8 +20,7 @@ class TestAnimationController extends AnimationController {
}
Future<void> execute() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
@@ -38,21 +37,17 @@ Future<void> execute() async {
for (final int callbackCount in callbackCounts) {
final int iterations = totalIterations ~/ callbackCount;
final ObserverList<VoidCallback> observerList =
ObserverList<VoidCallback>();
final ObserverList<VoidCallback> observerList = ObserverList<VoidCallback>();
for (int i = 0; i < callbackCount; ++i) {
observerList.add(
switch (failRemoval) {
false => () {
final VoidCallback first =
(observerList.iterator..moveNext()).current;
observerList.add(switch (failRemoval) {
false => () {
final VoidCallback first = (observerList.iterator..moveNext()).current;
observerList.remove(first);
observerList.add(first);
},
true => () => observerList.remove(miss),
observerList.remove(first);
observerList.add(first);
},
);
true => () => observerList.remove(miss),
});
}
final Stopwatch watch = Stopwatch()..start();
@@ -79,21 +74,16 @@ Future<void> execute() async {
}
}
void runNotifyListenersLoopWithHashedObserverList(
int totalIterations, {
bool addResult = true,
}) {
void runNotifyListenersLoopWithHashedObserverList(int totalIterations, {bool addResult = true}) {
const String name = 'notifyListeners:HashedObserverList';
for (final int callbackCount in callbackCounts) {
final int iterations = totalIterations ~/ callbackCount;
final HashedObserverList<VoidCallback> observerList =
HashedObserverList<VoidCallback>();
final HashedObserverList<VoidCallback> observerList = HashedObserverList<VoidCallback>();
for (int i = 0; i < callbackCount; ++i) {
observerList.add(() {
final VoidCallback first =
(observerList.iterator..moveNext()).current;
final VoidCallback first = (observerList.iterator..moveNext()).current;
observerList.remove(first);
observerList.add(first);
@@ -124,10 +114,7 @@ Future<void> execute() async {
}
}
void runNotifyListenersLoopWithAnimationController(
int totalIterations, {
bool addResult = true,
}) {
void runNotifyListenersLoopWithAnimationController(int totalIterations, {bool addResult = true}) {
const String name = 'notifyListeners:AnimationController';
for (final int callbackCount in callbackCounts) {
@@ -163,8 +150,7 @@ Future<void> execute() async {
}
runNotifyListenersLoopWithObserverList(_kNumIterationsList);
runNotifyListenersLoopWithObserverList(_kNumIterationsList,
failRemoval: true);
runNotifyListenersLoopWithObserverList(_kNumIterationsList, failRemoval: true);
runNotifyListenersLoopWithHashedObserverList(_kNumIterationsHashed);
runNotifyListenersLoopWithAnimationController(_kNumIterationsHashed);

View File

@@ -11,8 +11,7 @@ const int _kBatchSize = 100;
const int _kNumIterations = 100;
Future<void> execute() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
WidgetsFlutterBinding.ensureInitialized();
final Stopwatch watch = Stopwatch();
@@ -27,7 +26,10 @@ Future<void> execute() async {
// We don't load images like this. PlatformAssetBundle is used for
// other assets (like Rive animations). We are using an image because it's
// conveniently sized and available for the test.
tally += (await bundle.load('packages/flutter_gallery_assets/places/india_pondicherry_salt_farm.png')).lengthInBytes;
tally +=
(await bundle.load(
'packages/flutter_gallery_assets/places/india_pondicherry_salt_farm.png',
)).lengthInBytes;
}
watch.stop();
values.add(watch.elapsedMicroseconds.toDouble() / _kBatchSize);

View File

@@ -9,8 +9,7 @@ import '../common.dart';
const int _kNumIterations = 100000;
Future<void> execute() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
const StandardMessageCodec codec = StandardMessageCodec();

View File

@@ -9,8 +9,7 @@ import '../common.dart';
const int _kNumIterations = 100000;
Future<void> execute() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
const StandardMethodCodec codec = StandardMethodCodec();
@@ -47,8 +46,7 @@ Future<void> execute() async {
watch.start();
for (int i = 0; i < _kNumIterations; i += 1) {
codec.encodeMethodCall(
const MethodCall(methodName, 'This is a performance test.'));
codec.encodeMethodCall(const MethodCall(methodName, 'This is a performance test.'));
}
watch.stop();
@@ -62,8 +60,9 @@ Future<void> execute() async {
watch.reset();
watch.start();
for (int i = 0; i < _kNumIterations; i += 1) {
codec.encodeMethodCall(const MethodCall(
methodName, <Object>[1234, 'This is a performance test.', 1.25, true]));
codec.encodeMethodCall(
const MethodCall(methodName, <Object>[1234, 'This is a performance test.', 1.25, true]),
);
}
watch.stop();
@@ -77,12 +76,14 @@ Future<void> execute() async {
watch.reset();
watch.start();
for (int i = 0; i < _kNumIterations; i += 1) {
codec.encodeMethodCall(const MethodCall(methodName, <String, Object>{
'integer': 1234,
'string': 'This is a performance test.',
'float': 1.25,
'boolean': true,
}));
codec.encodeMethodCall(
const MethodCall(methodName, <String, Object>{
'integer': 1234,
'string': 'This is a performance test.',
'float': 1.25,
'boolean': true,
}),
);
}
watch.stop();

View File

@@ -9,8 +9,7 @@ import '../common.dart';
const int _kNumIterations = 10000;
Future<void> execute() async {
assert(false,
"Don't run benchmarks in debug mode! Use 'flutter run --release'.");
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
final Stopwatch watch = Stopwatch();
@@ -31,13 +30,16 @@ Future<void> execute() async {
watch.reset();
watch.start();
for (int i = 0; i < _kNumIterations; i += 1) {
FlutterTimeline.startSync('foo', arguments: <String, dynamic>{
'int': 1234,
'double': 0.3,
'list': <int>[1, 2, 3, 4],
'map': <String, dynamic>{'map': true},
'bool': false,
});
FlutterTimeline.startSync(
'foo',
arguments: <String, dynamic>{
'int': 1234,
'double': 0.3,
'list': <int>[1, 2, 3, 4],
'map': <String, dynamic>{'map': true},
'bool': false,
},
);
FlutterTimeline.finishSync();
}
watch.stop();

View File

@@ -8,7 +8,12 @@ import '../common.dart';
const int _kNumIters = 10000;
void _testCurve(Curve curve, {required String name, required String description, required BenchmarkResultPrinter printer}) {
void _testCurve(
Curve curve, {
required String name,
required String description,
required BenchmarkResultPrinter printer,
}) {
final Stopwatch watch = Stopwatch();
print('$description benchmark...');
watch.start();

View File

@@ -11,7 +11,7 @@ import '../common.dart';
const int _kNumIterations = 10000000;
const int _kNumWarmUp = 100000;
Future<void> execute() async {
Future<void> execute() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
print('MatrixUtils.transformRect and .transformPoint benchmark...');
@@ -24,14 +24,18 @@ Future<void> execute() async {
}
final List<Matrix4> affineTransforms = <Matrix4>[
Matrix4.identity()..scale(1.2, 1.3, 1.0)..rotateZ(0.1),
Matrix4.identity()
..scale(1.2, 1.3, 1.0)
..rotateZ(0.1),
Matrix4.identity()..translate(12.0, 13.0, 10.0),
Matrix4.identity()..scale(1.2, 1.3, 1.0)..translate(12.0, 13.0, 10.0),
Matrix4.identity()
..scale(1.2, 1.3, 1.0)
..translate(12.0, 13.0, 10.0),
];
final List<Matrix4> perspectiveTransforms = <Matrix4>[
makePerspective(10.0, math.pi / 8.0, 0.3),
makePerspective( 8.0, math.pi / 8.0, 0.2),
makePerspective( 1.0, math.pi / 4.0, 0.1)..rotateX(0.1),
makePerspective(8.0, math.pi / 8.0, 0.2),
makePerspective(1.0, math.pi / 4.0, 0.1)..rotateX(0.1),
];
final List<Rect> rectangles = <Rect>[
const Rect.fromLTRB(1.1, 1.2, 1.5, 1.8),

View File

@@ -12,7 +12,6 @@ class ButtonMatrixApp extends StatefulWidget {
}
class ButtonMatrixAppState extends State<ButtonMatrixApp> {
int count = 1;
int increment = 1;
@@ -24,7 +23,10 @@ class ButtonMatrixAppState extends State<ButtonMatrixApp> {
title: Text('Count: $count'),
actions: <Widget>[
TextButton(
onPressed: () => setState(() { count += increment; }),
onPressed:
() => setState(() {
count += increment;
}),
child: Text('Add $increment'),
),
],
@@ -38,7 +40,10 @@ class ButtonMatrixAppState extends State<ButtonMatrixApp> {
10,
TextButton(
child: const Text('Faster'),
onPressed: () => setState(() { increment += 1; }),
onPressed:
() => setState(() {
increment += 1;
}),
),
),
),

View File

@@ -11,7 +11,7 @@ import 'data/velocity_tracker_data.dart';
const int _kNumIters = 10000;
class TrackerBenchmark {
TrackerBenchmark({required this.name, required this.tracker });
TrackerBenchmark({required this.name, required this.tracker});
final VelocityTracker tracker;
final String name;
@@ -21,10 +21,14 @@ Future<void> execute() async {
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
final List<TrackerBenchmark> benchmarks = <TrackerBenchmark>[
TrackerBenchmark(name: 'velocity_tracker_iteration',
tracker: VelocityTracker.withKind(PointerDeviceKind.touch)),
TrackerBenchmark(name: 'velocity_tracker_iteration_ios_fling',
tracker: IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch)),
TrackerBenchmark(
name: 'velocity_tracker_iteration',
tracker: VelocityTracker.withKind(PointerDeviceKind.touch),
),
TrackerBenchmark(
name: 'velocity_tracker_iteration_ios_fling',
tracker: IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch),
),
];
final Stopwatch watch = Stopwatch();

View File

@@ -19,8 +19,7 @@ class Data {
}
List<Data> test(int length) {
return List<Data>.generate(length,
(int index) => Data(index * index));
return List<Data>.generate(length, (int index) => Data(index * index));
}
Future<void> execute() async {

View File

@@ -11,20 +11,17 @@ const int _kNumWarmUp = 100;
Future<void> execute() async {
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'
' printer took a galley of type and scrambled it to make a'
' type specimen book'.split(' ');
" typesetting industry. Lorem Ipsum has been the industry's"
' standard dummy text ever since the 1500s, when an unknown'
' printer took a galley of type and scrambled it to make a'
' type specimen book'
.split(' ');
final List<InlineSpanSemanticsInformation> data = <InlineSpanSemanticsInformation>[];
for (int i = 0; i < words.length; i++) {
if (i.isEven) {
data.add(
InlineSpanSemanticsInformation(words[i]),
);
data.add(InlineSpanSemanticsInformation(words[i]));
} else if (i.isEven) {
data.add(
InlineSpanSemanticsInformation(words[i], isPlaceholder: true),
);
data.add(InlineSpanSemanticsInformation(words[i], isPlaceholder: true));
}
}
print(words);
@@ -77,13 +74,17 @@ String consumeSpan(Iterable<InlineSpanSemanticsInformation> items) {
return result;
}
Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<InlineSpanSemanticsInformation> inputs) sync* {
Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(
List<InlineSpanSemanticsInformation> inputs,
) sync* {
String workingText = '';
String? workingLabel;
for (final InlineSpanSemanticsInformation info in inputs) {
if (info.requiresOwnNode) {
yield InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText);
yield InlineSpanSemanticsInformation(
workingText,
semanticsLabel: workingLabel ?? workingText,
);
workingText = '';
workingLabel = null;
yield info;
@@ -97,13 +98,17 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin
assert(workingLabel != null);
}
Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpanSemanticsInformation> inputs) {
Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(
List<InlineSpanSemanticsInformation> inputs,
) {
String workingText = '';
String? workingLabel;
final List<InlineSpanSemanticsInformation> result = <InlineSpanSemanticsInformation>[];
for (final InlineSpanSemanticsInformation info in inputs) {
if (info.requiresOwnNode) {
result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText));
result.add(
InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText),
);
workingText = '';
workingLabel = null;
result.add(info);

View File

@@ -13,11 +13,7 @@ const Duration kBenchmarkTime = Duration(seconds: 15);
// Use an Align to loosen the constraints.
final Widget intrinsicTextHeight = Directionality(
textDirection: TextDirection.ltr,
child: Align(
child: IntrinsicHeight(
child: Text('A' * 100),
),
),
child: Align(child: IntrinsicHeight(child: Text('A' * 100))),
);
Future<void> execute() async {
@@ -25,7 +21,8 @@ Future<void> execute() async {
// We control the framePolicy below to prevent us from scheduling frames in
// the engine, so that the engine does not interfere with our timings.
final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as LiveTestWidgetsFlutterBinding;
final LiveTestWidgetsFlutterBinding binding =
TestWidgetsFlutterBinding.ensureInitialized() as LiveTestWidgetsFlutterBinding;
final Stopwatch watch = Stopwatch();
int iterations = 0;
@@ -55,7 +52,6 @@ Future<void> execute() async {
watch.stop();
});
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
printer.addResult(
description: 'Text intrinsic height',

View File

@@ -17,7 +17,8 @@ Future<List<double>> runBuildBenchmark() async {
// We control the framePolicy below to prevent us from scheduling frames in
// the engine, so that the engine does not interfere with our timings.
final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as LiveTestWidgetsFlutterBinding;
final LiveTestWidgetsFlutterBinding binding =
TestWidgetsFlutterBinding.ensureInitialized() as LiveTestWidgetsFlutterBinding;
final Stopwatch watch = Stopwatch();
int iterations = 0;

View File

@@ -18,7 +18,8 @@ Future<void> execute() async {
// We control the framePolicy below to prevent us from scheduling frames in
// the engine, so that the engine does not interfere with our timings.
final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as LiveTestWidgetsFlutterBinding;
final LiveTestWidgetsFlutterBinding binding =
TestWidgetsFlutterBinding.ensureInitialized() as LiveTestWidgetsFlutterBinding;
final Stopwatch watch = Stopwatch();
int iterations = 0;

View File

@@ -86,8 +86,7 @@ Future<void> execute() async {
watch.start();
for (int i = 0; i < 10; i += 1) {
await Future.wait(<Future<ui.ImmutableBuffer>>[
for (final String asset in assets)
rootBundle.loadBuffer(asset)
for (final String asset in assets) rootBundle.loadBuffer(asset),
]);
}
watch.stop();