Reduce noise on the memory benchmarks (#19630)
- Check memory usage in release builds, not profile. - Use multiple runs and average the results.
This commit is contained in:
@@ -447,19 +447,19 @@ class FlutterDriver {
|
||||
/// ensure the item's final position matches [alignment].
|
||||
///
|
||||
/// The [scrollable] must locate the scrolling widget that contains [item].
|
||||
/// Typically `find.byType('ListView') or `find.byType('CustomScrollView')`.
|
||||
/// Typically `find.byType('ListView')` or `find.byType('CustomScrollView')`.
|
||||
///
|
||||
/// Atleast one of [dxScroll] and [dyScroll] must be non-zero.
|
||||
/// At least one of [dxScroll] and [dyScroll] must be non-zero.
|
||||
///
|
||||
/// If [item] is below the currently visible items, then specify a negative
|
||||
/// value for [dyScroll] that's a small enough increment to expose [item]
|
||||
/// without potentially scrolling it up and completely out of view. Similarly
|
||||
/// if [item] is above, then specify a positve value for [dyScroll].
|
||||
/// if [item] is above, then specify a positive value for [dyScroll].
|
||||
///
|
||||
/// If [item] is to the right of the the currently visible items, then
|
||||
/// If [item] is to the right of the currently visible items, then
|
||||
/// specify a negative value for [dxScroll] that's a small enough increment to
|
||||
/// expose [item] without potentially scrolling it up and completely out of
|
||||
/// view. Similarly if [item] is to the left, then specify a positve value
|
||||
/// view. Similarly if [item] is to the left, then specify a positive value
|
||||
/// for [dyScroll].
|
||||
///
|
||||
/// The [timeout] value should be long enough to accommodate as many scrolls
|
||||
@@ -483,7 +483,7 @@ class FlutterDriver {
|
||||
// the chance to complete if the item is already onscreen; if not, scroll
|
||||
// repeatedly until we either find the item or time out.
|
||||
bool isVisible = false;
|
||||
waitFor(item, timeout: timeout).then((Null _) { isVisible = true; });
|
||||
waitFor(item, timeout: timeout).then((Null value) { isVisible = true; });
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
while (!isVisible) {
|
||||
await scroll(scrollable, dxScroll, dyScroll, const Duration(milliseconds: 100));
|
||||
|
||||
@@ -146,7 +146,7 @@ class FlutterDriverExtension {
|
||||
|
||||
static final Logger _log = new Logger('FlutterDriverExtension');
|
||||
|
||||
final WidgetController _prober = new WidgetController(WidgetsBinding.instance);
|
||||
final WidgetController _prober = new LiveWidgetController(WidgetsBinding.instance);
|
||||
final Map<String, CommandHandlerCallback> _commandHandlers = <String, CommandHandlerCallback>{};
|
||||
final Map<String, CommandDeserializerCallback> _commandDeserializers = <String, CommandDeserializerCallback>{};
|
||||
final Map<String, FinderConstructor> _finders = <String, FinderConstructor>{};
|
||||
|
||||
@@ -15,8 +15,12 @@ import 'test_pointer.dart';
|
||||
|
||||
/// Class that programmatically interacts with widgets.
|
||||
///
|
||||
/// For a variant of this class suited specifically for unit tests, see [WidgetTester].
|
||||
class WidgetController {
|
||||
/// For a variant of this class suited specifically for unit tests, see
|
||||
/// [WidgetTester]. For one suitable for live tests on a device, consider
|
||||
/// [LiveWidgetController].
|
||||
///
|
||||
/// Concrete subclasses must implement the [pump] method.
|
||||
abstract class WidgetController {
|
||||
/// Creates a widget controller that uses the given binding.
|
||||
WidgetController(this.binding);
|
||||
|
||||
@@ -392,10 +396,11 @@ class WidgetController {
|
||||
/// This is invoked by [flingFrom], for instance, so that the sequence of
|
||||
/// pointer events occurs over time.
|
||||
///
|
||||
/// The default implementation does nothing.
|
||||
///
|
||||
/// The [WidgetTester] subclass implements this by deferring to the [binding].
|
||||
Future<Null> pump(Duration duration) => new Future<Null>.value(null);
|
||||
///
|
||||
/// See also [SchedulerBinding.endOfFrame], which returns a future that could
|
||||
/// be appropriate to return in the implementation of this method.
|
||||
Future<Null> pump(Duration duration);
|
||||
|
||||
/// Attempts to drag the given widget by the given offset, by
|
||||
/// starting a drag in the middle of the widget.
|
||||
@@ -516,3 +521,20 @@ class WidgetController {
|
||||
/// the widget's render object has been laid out at least once.
|
||||
Rect getRect(Finder finder) => getTopLeft(finder) & getSize(finder);
|
||||
}
|
||||
|
||||
/// Variant of [WidgetController] that can be used in tests running
|
||||
/// on a device.
|
||||
///
|
||||
/// This is used, for instance, by [FlutterDriver].
|
||||
class LiveWidgetController extends WidgetController {
|
||||
/// Creates a widget controller that uses the given binding.
|
||||
LiveWidgetController(WidgetsBinding binding) : super(binding);
|
||||
|
||||
@override
|
||||
Future<Null> pump(Duration duration) async {
|
||||
if (duration != null)
|
||||
await new Future<void>.delayed(duration);
|
||||
binding.scheduleFrame();
|
||||
await binding.endOfFrame;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,11 +360,11 @@ Future<Null> _buildGradleProjectV2(
|
||||
|
||||
command.add(assembleTask);
|
||||
final int exitCode = await runCommandAndStreamOutput(
|
||||
command,
|
||||
workingDirectory: flutterProject.android.directory.path,
|
||||
allowReentrantFlutter: true,
|
||||
environment: _gradleEnv,
|
||||
filter: logger.isVerbose ? null : ndkMessageFilter,
|
||||
command,
|
||||
workingDirectory: flutterProject.android.directory.path,
|
||||
allowReentrantFlutter: true,
|
||||
environment: _gradleEnv,
|
||||
filter: logger.isVerbose ? null : ndkMessageFilter,
|
||||
);
|
||||
status.stop();
|
||||
|
||||
|
||||
@@ -302,10 +302,11 @@ String runSync(List<String> cmd, {
|
||||
|
||||
void _traceCommand(List<String> args, { String workingDirectory }) {
|
||||
final String argsText = args.join(' ');
|
||||
if (workingDirectory == null)
|
||||
printTrace(argsText);
|
||||
else
|
||||
printTrace('[$workingDirectory${fs.path.separator}] $argsText');
|
||||
if (workingDirectory == null) {
|
||||
printTrace('executing: $argsText');
|
||||
} else {
|
||||
printTrace('executing: [$workingDirectory${fs.path.separator}] $argsText');
|
||||
}
|
||||
}
|
||||
|
||||
String _runWithLoggingSync(List<String> cmd, {
|
||||
|
||||
Reference in New Issue
Block a user