James Williams
LinkedInMastodonGithub

Stats.dart

Tags: Dart

This past weekend I attended the Silicon Valley incarnation of the Happy Hourglobal DART hackathon. On Friday night, there was a short presentation, pitches, and team formation. After dropping off one of my teammates at the Caltrain station, I was itching to code something in Dart as a ramp-up to the large amount of coding I knew I'd be doing on Saturday. I decided to port Stats.js to Dart.

Stat.js is a performance monitor that allows you to determine the frame rate and number of milliseconds it takes to render your scenes. It's a great tool to have when you are creating animations with Canvas2D or WebGL. Stats.dart is a more Dart-y version. It was completed in a couple hours on Friday night and Saturday morning thanks to Dart's familiarity.

To use it, instantiate a Stats object by calling new Stats() somewhere in your code and call the update() function in your render loop.

Below we can see screencaps of the FPS and MS calculations

Stats.dart FPS Display Stats.dart MS Display

As this was a quick hack, I will probably be continually cleaning up some things.

Github: https://github.com/jwill/stats.dart