forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce noise on the memory benchmarks (flutter#19630)
- Check memory usage in release builds, not profile. - Use multiple runs and average the results.
- Loading branch information
Showing
21 changed files
with
562 additions
and
218 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
dev/benchmarks/complex_layout/test_memory/scroll_perf.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2016 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:async'; | ||
|
||
import 'package:complex_layout/main.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/scheduler.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
/// The speed, in pixels per second, that the drag gestures should end with. | ||
const double speed = 1500.0; | ||
|
||
/// The number of down drags and the number of up drags. The total number of | ||
/// gestures is twice this number. | ||
const int maxIterations = 4; | ||
|
||
/// The time that is allowed between gestures for the fling effect to settle. | ||
const Duration pauses = Duration(milliseconds: 500); | ||
|
||
Future<void> main() async { | ||
final Completer<void> ready = new Completer<void>(); | ||
runApp(new GestureDetector( | ||
onTap: () { | ||
debugPrint('Received tap.'); | ||
ready.complete(); | ||
}, | ||
behavior: HitTestBehavior.opaque, | ||
child: new IgnorePointer( | ||
ignoring: true, | ||
child: new ComplexLayoutApp(), | ||
), | ||
)); | ||
await SchedulerBinding.instance.endOfFrame; | ||
|
||
/// Wait 50ms to allow the GPU thread to actually put up the frame. (The | ||
/// endOfFrame future ends when we send the data to the engine, before the GPU | ||
/// thread has had a chance to rasterize, etc.) | ||
await new Future<Null>.delayed(const Duration(milliseconds: 50)); | ||
debugPrint('==== MEMORY BENCHMARK ==== READY ===='); | ||
|
||
await ready.future; // waits for tap sent by devicelab task | ||
debugPrint('Continuing...'); | ||
|
||
// remove onTap handler, enable pointer events for app | ||
runApp(new GestureDetector( | ||
child: new IgnorePointer( | ||
ignoring: false, | ||
child: new ComplexLayoutApp(), | ||
), | ||
)); | ||
await SchedulerBinding.instance.endOfFrame; | ||
|
||
final WidgetController controller = new LiveWidgetController(WidgetsBinding.instance); | ||
|
||
// Scroll down | ||
for (int iteration = 0; iteration < maxIterations; iteration += 1) { | ||
debugPrint('Scroll down... $iteration/$maxIterations'); | ||
await controller.fling(find.byType(ListView), const Offset(0.0, -700.0), speed); | ||
await new Future<Null>.delayed(pauses); | ||
} | ||
|
||
// Scroll up | ||
for (int iteration = 0; iteration < maxIterations; iteration += 1) { | ||
debugPrint('Scroll up... $iteration/$maxIterations'); | ||
await controller.fling(find.byType(ListView), const Offset(0.0, 300.0), speed); | ||
await new Future<Null>.delayed(pauses); | ||
} | ||
|
||
debugPrint('==== MEMORY BENCHMARK ==== DONE ===='); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.