Flutter - Changing state as frequent as possible

Viewed 98

I am playing with flutter and trying to measure performance. My intention is to change state as often as possible and check how this framework is going to deal with it. I use WidgetsBinding.instance.addTimingsCallback to measure timing.

class _MyHomePageState extends State<MyHomePage> {

  void initState() {
    super.initState();
    WidgetsBinding.instance
      .addTimingsCallback((timing) {
        print(1000 ~/ timing.first.totalSpan.inMilliseconds);
        setState(() {
          // here I change state
        });
      });
  }

  [...]

For some reason, the print statement shows that total timing is ~40ms, but the state is changing only few times a second. Why is that? What am I missing?

I launch the app using XCode in release mode.

0 Answers
Related