Flash Player 10.1 Performance: Part 6
Today’s article is the conclusion of my series on Flash Player 10.0 versus Flash Player 10.1 performance. If you haven’t yet read the first, second, third, fourth, and fifth articles, that’s a good place to start. If you have, read on for the finale!
Introduction
This part’s performance methodology will be the same as
String Conversion
Flash Player 10.0
Type | String() | Concat | toString() | toString(10) | join() | for loop |
---|---|---|---|---|---|---|
int | 2 | 262 | 328 | 328 | n/a | n/a |
uint | 2 | 262 | 330 | 330 | n/a | n/a |
Number | 2 | 282 | 323 | 324 | n/a | n/a |
Boolean | 2 | 2 | 9 | n/a | n/a | n/a |
Array | 5901 | 5886 | 5861 | n/a | 5507 | 3782 |
Vector (int) | 5364 | 5379 | 4975 | n/a | 5127 | 3834 |
Flash Player 10.1
Type | String() | Concat | toString() | toString(10) | join() | for loop |
---|---|---|---|---|---|---|
int | 2 | 1 | 196 | 194 | n/a | n/a |
uint | 2 | 2 | 194 | 201 | n/a | n/a |
Number | 1 | 1 | 199 | 190 | n/a | n/a |
Boolean | 2 | 2 | 9 | n/a | n/a | n/a |
Array | 2659 | 2671 | 2640 | n/a | 2633 | 1465 |
Vector (int) | 2493 | 2490 | 2265 | n/a | 2250 | 1389 |
First off, concatenation of int
, uint
, and Number
has gone from 262-282 to 1-2, which is a huge speedup. While not quite as huge, all other string conversions seem to have roughly doubled in speed. These are some great performance increases across the board!
Arguments Slowdown
Flash Player 10.0
Environment | Plain (1) | Var Args (1) | arguments (1) | Plain (25) | Var Args (25) | arguments (25) |
---|---|---|---|---|---|---|
Flash Player 10.0 | 10 | 379 | 493 | 21 | 825 | 1148 |
Flash Player 10.1 | 10 (1x) | 191 (1.9x) | 437 (1.1x) | 21 (1x) | 639 (1.3x) | 1067 (1.1x) |
Again, there are speedups here across the board. This time they range from 1x (undetectable at small timing) for plain functions to 1.9x in the extreme case. Since var args and arguments
are both important and often-used language features, this should come as a welcome speedup to many AS3 apps.
Variable Ordering
Flash Player 10.0
Environment | testIFirst | testILast |
---|---|---|
Flash Player 10.0 | 6876 | 6939 |
Flash Player 10.1 | 7399 | 7501 |
While the relative difference between variable orderings remains roughly unchanged—putting frequently-used variables first helps very slightly—the overall times have increased in Flash Player 10.1 by about 8%. Local variables are extremely common and the fastest way to access a variable, so it’s a real shame to see their speed drop for seemingly no reason.
Conclusion
After six articles of performance comparison between Flash Player 10.0 and Flash Player 10.1, one thing is certain: the performance differences are a definite mixed bag. Even in today’s tests we saw two across-the-board speedups and one across-the-board slowdown. It’s very important to keep in mind the relative weight to give each of these tests when trying to decide if Flash Player 10.1 represents an overall speedup and can flatly be described as “faster” or “slower” than Flash Player 10.0. The performance articles on this site aim to look very closely at the differences in different approaches, or in this case Players, so that the AS3 programmer can make more knowledgeable decisions to optimize Flash apps. So if you’re looking for the nitty gritty, read back over the first, second, third, fourth, and fifth articles. If you’re not, here are some performance generalizations:
Method | Speed Change | Importance | Notes |
---|---|---|---|
Object allocation | 2x-3x faster | Major | Free lists still 5x faster |
Loops | 2x faster | Major | Some types exhibit more modest speed improvements |
Shapes and Sprites | 1.5x faster | Major | 40% less memory too |
Function Calls Through Objects | 25-50% slower | Major | Calls through super not slower |
Getters and Setters | 50% slowdown | Major | |
Mapping Classes | 50% slower-50% faster | Major | Results extremely mixed. Array and Vector notably slower (19-33%) |
Events | 1.2x faster | Major | Still much slower than TurboSignals |
Local Variables | 8% slower | Major | First variables still slightly faster |
Calls through Function variables | 3.5x faster | Average | |
Try/catch | 1.5x-3x faster | Average | No longer any slowdown |
Var Args | 2x faster | Average | |
Math functions | 1.1x-2x faster | Average | Inline versions often much faster |
BitmapData | Mostly 0-30% faster | Average | Some functions massively faster, others slower |
Graphics.lineTo() | 8-167% faster | Average | |
Decrements | 17% faster | Average | |
Var Args and Arguments | 1.3x-1.9x faster | Average | |
Namespaces | 25% slower | Minor | |
Building XML | 6.5x faster | Minor | |
Regular Expressions | 30% faster | Minor | |
Math.isNaN() | 70% faster | Minor | Inline version still much faster |
Backwards Loops | 17% slower | Minor | |
Linked Lists | 1.15x-2.58x faster | Minor | |
Sorting Vectors | 1-46% faster | Minor | Array.sortOn() still much faster |
Math.ceil | 2x faster | Minor | Inline version still 1.8 faster |
Conversion to String | 2x faster | Minor | Concatenation is wildly faster |
Among the tests I marked “major”, there are big speedups and big slowdowns. While it’s certainly awesome to have 2x-3x faster object allocation, 2x faster loops, 1.5x faster Shapes
and Sprites
, and 1.2x faster Events, it’s also a huge letdown to have 25-50% slower calls through Function
variables, 50% slower getters and setters, 19-33% slower Arrays
and Vectors
, and 8% slower local variables. So is this faster or slower overall? With such varied results, the answer must ultimately depend on where your program’s bottleneck lies. Overall though, I’d say most Flash apps should be a little quicker with Flash Player 10.1.
#1 by Burak KALAYCI on August 11th, 2010 ·
Thanks for the articles. Interesting results – some did surprise me.
#2 by skyboy on October 25th, 2010 ·
I was looking for an appropriate place to post this, but couldn’t find one, but this is related.
traverse (10000 operations): 29341 array/5963 list
Run in the debug player. This shows just how slow the debugline operation is in 10.1 standalone debug player, since the array is usually 2-3 times faster.
There has to be a better way to mark what line code is than doing it as an operation that takes so much time, such as a look-up table.
#3 by jonathanasdf on January 25th, 2011 ·
Time for another series?
http://labs.adobe.com/downloads/flashplayer10.html
:D Looking forwards to it!
#4 by jackson on January 25th, 2011 ·
Perhaps when 10.2 is out and finalized. There have been plenty more (20+) performance articles in the last six months, so the next series would be even longer. Yikes!
#5 by skyboy on January 25th, 2011 ·
You may want to structure them more as unit tests so you can easily recompile a single SWF, and add new tests for when the next version is released. It’d save a fair amount of time each time Adobe releases a new version once it’s set up; You might even make it open source (ie. github) for others to run their own tests easily.
#6 by jackson on January 25th, 2011 ·
It doesn’t get any more open source than posting the whole test app in the body of the article. :) But seriously, I’ll consider posting all the sources to some common location.
As for an automated way to run the tests, I really do like to keep them minimal so as to make absolutely sure that I’m testing only the code in question. Also, I like the tests to be able to run stand-alone outside of any framework. That said, it’s actually pretty easy to re-run the tests as I have the sources compiled on my local drive so I simply need to re-run them. The really time-consuming part is creating the result data tables and analyzing that data for the article. Hence the breakdown into six parts last time.
#7 by jonathanasdf on February 8th, 2011 ·
http://www.bytearray.org/?p=2740
#8 by jackson on February 8th, 2011 ·
You don’t waste any time, do you? ;-)
I too have already started looking at it. Perhaps there will be a 10 part series soon…
#9 by skyboy on February 8th, 2011 ·
With some luck
ByteArray::readObject
will be faster, bodes well for my JSON class if it is.#10 by skyboy on February 5th, 2011 ·
Again with my unrelated yet related posts.
I’ve checked around a little and didn’t notice any links that stood out: Have
local var / static var / special alchemy op codes
been directly compared against one-another?I’ve been playing around with haXe and decided to rewrite my JSON class in an attempt to get parsing my test-case input down to the single digits. Since read/writing application memory through the Memory class is probably faster than static variables, I store a few ints there as well as directly write raw AS3 object data after some padding space from the input data in an attempt to avoid penalties (particularly with allocating new objects), I’ll find out if it works or not when I’m done.
But I’m still curious, are alchemy opcodes faster than local variable access?
I know they’re faster than accessing fields of Array or Vector, but that’s as far as extensive knowledge of them goes.
#11 by jackson on February 5th, 2011 ·
I actually don’t have any direct test comparing local variables to fields, static or not. I also don’t have any tests whatsoever involving the Alchemy opcodes. Both are good ideas for articles, so stay tuned!
Can’t wait to see how fast your JSON class can get. I haven’t done much XML testing here either, so my idea of its performance is pretty vague. It’s off-topic, but any idea how your JSON compares to parsing and accessing XML?
#12 by skyboy on February 5th, 2011 ·
I haven’t actually tested XML, however, being implemented in C++, that parser certain has the chance to be faster than my parser.
But from what I recall it took 2 ms to parse a string less than 1/100th the size of my test-case (nearly 500,000 characters); Which would make it hundreds of times slower, most likely something to do with object allocation as well. (If you do test XML at some point, my pure AS3 JSON class averages just under 0.001 ms per character)