Unverified Commit db705b81 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Restore the original name of the velocity tracker microbenchmark (#64060)

parent ce63f507
......@@ -13,3 +13,10 @@ flutter run --release lib/stocks/layout_bench.dart
```
The results should be in the device logs.
### Avoid changing names of the benchmarks
Each microbenchmark is identified by a name, for example,
"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.
......@@ -9,15 +9,25 @@ import 'data/velocity_tracker_data.dart';
const int _kNumIters = 10000;
class TrackerBenchmark {
TrackerBenchmark({ this.name, this.tracker });
final VelocityTracker tracker;
final String name;
}
void main() {
assert(false, "Don't run benchmarks in checked mode! Use 'flutter run --release'.");
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
final List<VelocityTracker> trackers = <VelocityTracker>[VelocityTracker(), IOSScrollViewFlingVelocityTracker()];
final List<TrackerBenchmark> benchmarks = <TrackerBenchmark>[
TrackerBenchmark(name: 'velocity_tracker_iteration', tracker: VelocityTracker()),
TrackerBenchmark(name: 'velocity_tracker_iteration_ios_fling', tracker: IOSScrollViewFlingVelocityTracker()),
];
final Stopwatch watch = Stopwatch();
for (final VelocityTracker tracker in trackers) {
final String trackerType = tracker.runtimeType.toString();
print('$trackerType benchmark...');
for (final TrackerBenchmark benchmark in benchmarks) {
print('${benchmark.name} benchmark...');
final VelocityTracker tracker = benchmark.tracker;
watch.reset();
watch.start();
for (int i = 0; i < _kNumIters; i += 1) {
......@@ -30,10 +40,10 @@ void main() {
}
watch.stop();
printer.addResult(
description: 'Velocity tracker: $trackerType',
description: 'Velocity tracker: ${tracker.runtimeType}',
value: watch.elapsedMicroseconds / _kNumIters,
unit: 'µs per iteration',
name: 'velocity_tracker_iteration_$trackerType',
name: benchmark.name,
);
}
......
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