As we begin pushing Flutter to more platforms such as Desktop and Web, it is becoming increasingly important to quickly and easily measure performance of your application. While the built-in performance monitor gets the job done, it leaves a lot to be desired in terms of readability and flexibility.
As the old school Flash devs we are, we remember the days when virtually every Flash application around would use the hi-res-stats package by mrdoob (yes, that mrdoob). It was extremely helpful to catch performance issues, and make sure your application was smooth (which in those days, was a solid 24fps!).
Currently nothing like that exists in the Flutter community. To help fill this gap, we’ve created StatsFl! Available now on pub.dev: https://pub.dev/packages/statsfl
To use, just wrap your root view (or really, any view) in the StatsFl widget:
With that simple change you’ll get a discrete FPS history chart in the top-left of your application! By default it will show your last 15 seconds of activity, with two samples each second.
For the most part the default options should be all you need but just in case, we’ve made it fairly configurable. The image below shows StatsFl in 3 configurations.
As you can see, alignment, width and height are all adjustable. You can even toggle off showText for a minimalist mode (bottom).
Additionally, you can adjust the sampleTime and totalTime to be as long as you need. In this example, we’re calculating every .5 seconds, over a 15 second period, for a total of 30 samples.
return StatsFl( sampleTime: .5, //Interval between fps calculations, in seconds. totalTime: 15, //Total length of timeline, in seconds. child: MyApp());
If you like the package, please toss a thumbs up on pub.dev to help increase the popularity!
If at gskinner you are enthusiastic about Flutter, as a 20 years long Flash/AIR developer, I will consider stepping into flutter too. Love from Italy.