When I built the original PerformanceTest, I hacked it together quickly to meet a specific need I had at the time. As I used it, I found I needed more capability, and I became increasingly frustrated with both the messy code, and the poorly thought out API.

In response to feedback, and my own frustrations, I've completely rebuilt PerformanceTest to be more robust, extensible, feature-rich, *and* easier to use.

Core features:

  • Track time, memory usage and retained (unreleased) memory for functions.
  • Test rendering time for any display object.
  • Write simple one line tests, or build formal test suites.
  • Test suites can be built using inheritance or aggregation/composition.
  • Trace simple text results, or access robust XML reports.
  • Save XML and compare results between different versions of your code, or on different Flash players.
  • Easily build logging classes to analyze or visualize results.
  • Run multiple iterations of tests to get min, max, and deviation values.
  • Run tests synchronously, or queue them to run them asynchronously.
  • Listen for events from tests, test suites, and PerformanceTest.
  • Integrates easily with TDD by facilitating the creation of tests for time, memory, and retained memory limits.

Here's a very simple demo:

In it's simplest form, you can use PerformanceTest in one line:

trace(PerformanceTest.run(myMethod));
trace(PerformanceTest.run(mySprite, "spriteRenderTest", iterations, loops));

You can go even simpler when testing methods, by using the ptest function shortcut:

trace(ptest(myMethod));
trace(ptest(myMethod, ["param"], "name", iterations, loops));

Want something a bit more robust? You can set up formal collections of tests using TestSuite. You can use these to set up suites of benchmarks to test different player platforms, or you can maintain them over the life of a project to track its performance profile by saving the XML Logs.

This is a beta. The docs are complete, but a little sparse. There are very few sample / demo files. It almost definitely has bugs. I also plan to add at least one more class/tool to it, for comparing XML logs.

Given that, I'd appreciate anyone who's interested checking it out and giving some feedback. Does it do what you need? Find any bugs? Is the API straightforward? How much more documentation do you need?

You can download PerformanceTest v2 here. As with pretty much all of the source code I release, it is licensed under the MIT license.


UPDATE: I just uploaded a new version with a working FLA. My apologies for the trouble with the original one. It also includes a *very* simple benchmark comparison tool.