360 Flex
I’m sure that many of you might not read to the end of this article, so I’m plugging the premiere Flex conference and my session here at the beginning. Earlier in the week Tom and John had posted that they only had 50 tickets left so I was gonna help remind everyone to grab a ticket…well, I checked the site today and it looks like they’re sold out…so, I guess for those who snoozed…you know the rest.
Also, if you’re interested in the content below and want to see more about how to use the Flex Builder 3 Profiler, I’ve got a lot of cool stuffs planned, so come check out my session at 360 Flex!
TextField performance and the Flex Builder 3 Profiler
While working on the internals of a display class, I ran into the following issue when attempting a compile.

I decided to use my handy dandy Flex Builder 3 Profiler to put this warning to the test. During the test I created a function call to test the addition assignment ( += ) operator, I then created one to use TextField.appendText(). In the test application I gave myself the ability to re-execute the test as many times as I wanted to without restarting the app.
Test Round 1
I set the tester to run each algorithm 10 times. I then ran this test set three times to get an average. Being that the Flex Builder Profiler samples and the fact that the reporting unit is milliseconds, you can see from the image below that 10 runs of these algorithms does not take long enough to really tell a difference. As a matter of fact, looking at the highlighted row in the third results shows that the Flash Player executes the code so fast that the cumulative time for 10 executions of main.main:_additionAssignmentTest was 0ms!

Test Round 2
Being that 10 executions didn’t take long enough, I bumped it up to 100. Here are the results. Notice that in the third execution, contrary to the warning I got in Flex Builder according to the sampling data the addition assigment test ran faster than the appendText()

Test Round 3
Now we’re bumping it up to 1000 executions apiece. Once again, in the second set of results below, the sampling data contradicted the Flex Builder warning.

Test Round 4
I decided to bump it up to 10000. As you can see in the first set of results below, once again the sampling data contradicted the Flex Builder warning.

Test Round 5
During the previous rounds, I tested by just sending the character “a” to the two append algorithms. This time I set the tests to run for 1000 executions and sent the append algorithms the loop iterator i.toString() – resulting in anything from 0 to 999. As you can see appendText() won this round with flying colors!

Conclusion
After viewing the results of these tests you can come to realize a couple things:
1. When you’re testing, don’t just run one test. As you can see, the sampling data can fluctuate. Performance results can not only vary based on the state of the operating enviroment, but also by the data you’re testing with. In other words, if you want to be sure on performance gain, either test with the closest matching use case to your application or if you’re just assessing general performance run many tests using different scenarios.
2. Although the addition assigment ( += ) was faster than the TextField.appendText() during a couple runs, for the most part, the warning in Flex Builder was right on the money. Especially in the case of running many executions with more characters being appended to the TextField text on each iteration.
3. The Flex Builder 3 Profiler ROCKS!
Oh, and one final thing. I’ve uploaded my Flex Builder 3 Project Archive for this performance test I ran…you can access it here:
http://www.iheartair.com/wp-content/uploads/2008/08/360Flex_Profiling_PerformanceComparison.zip
See you at 360!