WidgetRecorder class abstract

A recorder for benchmarking interactions with the framework by creating widgets.

To implement a benchmark, extend this class and implement createWidget.

Example:

class BenchListView extends WidgetRecorder {
  BenchListView() : super(name: benchmarkName);

  static const String benchmarkName = 'bench_list_view';

  @override
  Widget createWidget() {
    return Directionality(
      textDirection: TextDirection.ltr,
      child: _TestListViewWidget(),
    );
  }
}

class _TestListViewWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TestListViewWidgetState();
  }
}

class _TestListViewWidgetState extends State<_TestListViewWidget> {
  ScrollController scrollController;

  @override
  void initState() {
    super.initState();
    scrollController = ScrollController();
    Timer.run(() async {
      bool forward = true;
      while (true) {
        await scrollController.animateTo(
          forward ? 300 : 0,
          curve: Curves.linear,
          duration: const Duration(seconds: 1),
        );
        forward = !forward;
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      controller: scrollController,
      itemCount: 10000,
      itemBuilder: (BuildContext context, int index) {
        return Text('Item #$index');
      },
    );
  }
}
Inheritance
Implemented types

Constructors

WidgetRecorder({required String name, bool useCustomWarmUp = false})
Creates a widget benchmark recorder.

Properties

hashCode int
The hash code for this object.
no setterinherited
isTracingEnabled bool
Whether this recorder requires tracing using Chrome's DevTools Protocol's "Tracing" API.
finalinherited
name String
The name of the benchmark.
finalinherited
profile Profile
Returns the recorded profile.
getter/setter pairoverride-getter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useCustomWarmUp bool
Whether to delimit warm-up frames in a custom way.
final

Methods

createWidget() Widget
Creates a widget to be benchmarked.
frameDidDraw() → void
Called immediately after calling SchedulerBinding.handleDrawFrame.
override
frameWillDraw() → void
Called just before calling SchedulerBinding.handleDrawFrame.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerDidStop(VoidCallback fn) → void
Add a callback that will be called by the recorder when it stops recording.
override
run() Future<Profile>
The implementation of the benchmark that will produce a Profile.
override
setUpAll() Future<void>
Called once before all runs of this benchmark recorder.
inherited
shouldContinue() bool
Whether the benchmark should continue running.
inherited
tearDownAll() Future<void>
Called once after all runs of this benchmark recorder.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited