I recently decided to retest my results on uint, int and Number performance to see what had changed in Flash player 10 (more on that in my next post). I got a little carried away, and wound up building a generic performance testing harness for ActionScript 3. I've been meaning to do this for awhile, but hadn't gotten around to it until now. It's not that its very complicated, it just required a lot of thought into specifically how I would want it to work.

I think the nicest thing about the test harness is how flexible it is. You can easily use it to quickly test a couple of functions on the timeline, or you can build a full set of performance testing suites to support a project under development, similar to unit testing.

Even test suites are super simple. Point it at an instance of a class, and it will test all the public methods on it. Or, use properties or parameters to formalize the tests with names, descriptions, and specific method lists.

You can even use PerformanceTest to test the render time for complex vectors or filters.

You can also easily customize how it logs the results of tests to output them differently, save them to a file, or graph the results.

Here's a simple demo of it in action.

Note that this is a beta release. I'm considering a few more features, and possibly rearchitecting things a bit. For example, I'd like to make it easier to test renders as part of a suite. I'd also like to add a verbose mode that will run iterations asynchronously, and provide more advanced logging like min, max, and standard deviation for times.

I'll also be writing a series of blog entries over the next little while outlining (and hopefully explaining) some of the results I've been seeing from my tests.

If you have suggestions, or build some useful test suites, please feel free to share them in the comments or by emailing me with the contact button above.

UPDATE: Performance test has been updated with support for synchronous tests and integration with unit testing and test driven development. This release also fixes a bug with testFunction and testRender (pointed out by a few commenters below). You can download it from the link above. I will be posting a new version shortly with many more sample test suites.

UPDATE 2: PerformanceTest v2 beta has been released. It represents a very significant update from v1. Click here for information.

You can download version 1 of TestPerformance package, including API documentation and sample test suites by clicking here.