## Flash Player 10.1 Performance: Part 4

This fourth article in the series will be much like its predecessors: re-testing previous performance articles with Flash Player 10.1 and comparing the results to those that I got with Flash Player 10.0. While it mostly stands on its own, you should read up on the first, second, and third articles too. If you already have, read on for more performance comparisons!

###### Introduction

This part’s performance methodology will be the same as

###### BitmapData Alpha Performance

Light Functions (1000000 iterations)

Function | Flash Player 10.0 | Flash Player 10.1 |
---|---|---|

floodFill | 81 alpha, 80 no alpha, 1.25% speedup | 120 alpha, 118 no alpha, 1.69% speedup |

generateFilterRect | 453 alpha, 453 no alpha, 0% speedup | 325 alpha, 311 no alpha, 4.5% speedup |

getColorBoundsRect | 408 alpha, 411 no alpha, -0.73% speedup | 368 alpha, 365 no alpha, 0.82% speedup |

getPixel | 13 alpha, 10 no alpha, 30% speedup | 15 alpha, 13 no alpha, 15.38% speedup |

getPixel32 | 12 alpha, 9 no alpha, 33.33% speedup | 14 alpha, 13 no alpha, 7.69% speedup |

scroll | 28 alpha, 28 no alpha, 0% speedup | 33 alpha, 33 no alpha, 0% speedup |

setPixel | 46 alpha, 42 no alpha, 9.52% speedup | 44 alpha, 41 no alpha, 7.32% speedup |

setPixel32 | 45 alpha, 41 no alpha, 9.76% speedup | 45 alpha, 41 no alpha, 9.76% speedup |

Heavy Functions (1000 iterations)

Function | Flash Player 10.0 | Flash Player 10.1 |
---|---|---|

colorTransform | 6 alpha, 6 no alpha, 0% speedup | 0 alpha, 0 no alpha, 0% speedup |

clone | 33 alpha, 47 no alpha, -29.79% speedup | 92 alpha, 89 no alpha, 3.37% speedup |

fillRect | 4 alpha, 4 no alpha, 0% speedup | 4 alpha, 4 no alpha, 0% speedup |

getPixels | 549 alpha, 477 no alpha, 15.09% speedup | 528 alpha, 511 no alpha, 3.33% speedup |

getVector | 73 alpha, 60 no alpha, 21.67% speedup | 61 alpha, 49 no alpha, 24.45% speedup |

histogram | 110 alpha, 98 no alpha, 12.24% speedup | 170 alpha, 170 no alpha, 0% speedup |

noise | 291 alpha, 289 no alpha, 0.69% speedup | 293 alpha, 291 no alpha, 0.69% speedup |

perlinNoise | 905 alpha, 871 no alpha, 3.9% speedup | 876 alpha, 875 no alpha, 0.11% speedup |

setPixels | 48 alpha, 31 no alpha, 54.84% speedup | 49 alpha, 20 no alpha, 245% speedup |

setVector | 45 alpha, 13 no alpha, 246.15% speedup | 51 alpha, 12 no alpha, 425% speedup |

It seems that `BitmapData` performance is mostly unchanged in Flash Player 10.1 with the exception of some notable functions:

`generateFilterRect`is now about a quarter faster.- There is no longer a big performance penalty to
*not*using alpha with the`clone`function, but this comes at the cost of a slowdown of at least 100% to both alpha and non-alpha versions. `getPixels`and`getVector`are now marginally faster.`histogram`is now marginally slower.`setPixels`without alpha is now about a third faster.

###### For Vs. While

Function | Flash Player 10.0 | Flash Player 10.1 |
---|---|---|

for (forward) | 2218 | 2249 |

for (backward) | 2365 | 2018 |

while (forward) | 2217 | 2245 |

while (backward) | 2365 | 2020 |

The backwards for and while loops take a 17% hit in Flash Player 10.1, but thankfully they’re a lot less common than the unchanged forward one. Still, it’s a shame to see such a basic part of the language take such a big hit.

###### Fast Line Drawing

Function | Flash Player 10.0 | Flash Player 10.1 |
---|---|---|

efla | 64 | 69 |

lineTo (low) | 1 vector/79 bitmap | 1 vector/73 bitmap |

lineTo (medium) | 1 vector/325 bitmap | 1 vector/293 bitmap |

lineTo (high) | 1 vector/2588 bitmap | 1 vector/1024 bitmap |

lineTo (best) | 1 vector/5403 bitmap | 1 vector/3226 bitmap |

While the `efla` manual line drawing algorithm remains much the same as in Flash Player 10.0, the inbuilt `Graphics.lineTo` methods have received a very nice speedup that is especially pronounced when using higher stage quality. The speedups are as follows: low (8%), medium (11%), high (253%), best (167%). Even so, `efla` is always the fastest method to draw a simple line as it yields a 6%-4675% speedup depending on stage quality.

###### Linked Lists: Part 3

Function | Operations | Flash Player 10.0 | Flash Player 10.1 |
---|---|---|---|

traverse | 100 | 10 array/10 list | 8 array/7 list |

elementAt/[] | 100000 | 1 array/1160 list | 1 array/1013 list |

concat | 10 | 2 array/81 list | 5 array/52 list |

every | 10 | 7 array/10 list | 3 array/8 list |

filter | 10 | 9 array/44 list | 6 array/25 list |

forEach | 10 | 7 array/10 list | 3 array/9 list |

indexOf | 100 | 10 array/20 list | 11 array/22 list |

join | 1 | 14 array/17 list | 8 array/16 list |

lastIndexOf | 100 | 10 array/19 list | 10 array/23 list |

map | 1 | 1 array/3 list | 0 array/3 list |

pop | 100000 | 1 array/4 list | 1 array/1 list |

push | 100000 | 4 array/82 list | 4 array/44 list |

reverse | 100 | 11 array/101 list | 10 array/96 list |

shift | 10000 | 528 array/1 list | 527 array/0 list |

slice | 100 | 50 array/438 list | 36 array/262 list |

some | 1 | 7 array/9 list | 3 array/8 list |

sort | 1 | 460 array/496 list | 184 array/192 list |

sortOn | 1 | 110 array/155 list | 66 array/85 list |

splice | 10000 | 13 array/27 list | 10 array/17 list |

unshift | 10000 | 503 array/7 list | 505 array/3 list |

The linked list implementation is the focus here and it sees quite a few performance gains when upgrading from Flash Player 10.0 to Flash Player 10.1: `elementAt` (1.15x), `traverse` (1.43x), `concat` (1.56x), `splice` (1.59x), `slice` (1.67x), `filter` (1.76x), `sortOn` (1.82x), `push` (1.86x), `unshift` (2.33x), `sort` (2.58x), `pop` (4x). Still, the linked list is far slower than `Array` at most functions, but also far faster at two functions: `shift` (immeasurably faster) and `unshift` (168x). These are two classic linked list strong points and essentially the only reason you would choose to use one over an `Array` or `Vector` in AS3.

###### Callback Strategies

1 Argument

Function | Flash Player 10.0 | Flash Player 10.1 |
---|---|---|

Func (1 arg) | 67 | 18 |

Runnable (1 arg) | 4 | 5 |

Event (1 arg) | 1336 | 866 |

Signal (1 arg) | 1412 | 1033 |

Func (10 args) | 668 | 222 |

Runnable (10 args) | 180 | 165 |

Event (10 args) | 2877 | 2657 |

Signal (10 args) | 2804 | 1982 |

There are speedups across the board here, but they are especially strong for plain functions (3x), events (1.2x), and as3signals (1.3x-3x). In the interest of maintaining consistency between Flash Player 10.0 and Flash Player 10.1, I haven’t updated the version of as3signals used on this test. I understand that further performance gains can be had by updating to the latest version as this version is quite out of date.

###### More To Come

I’ve still got one or two more articles to go in this series as there are still more performance-related articles to cover, so stay tuned for more Flash Player 10.0 versus Flash Player 10.1 comparisons!