Flash Player 11.3 added a new way to compress and uncompress ByteArray
: the LZMA algorithm. This is useful because LZMA typically compresses to much smaller size than the existing zlib and deflate algorithms. But how much of a speed penalty does it incur? Today’s article seeks to find just that!
Posts Tagged performance
Try as I might, I just couldn’t find any articles about AS3’s finally
keyword. Sure I found Adobe’s documentation, but it seems no one is commenting any further about finally
. So today I’ll tackle the performance of what seems to be a straightforward keyword. Could it possibly cause a slowdown? Read on to find out!
AS3 has three kinds of loops—for
, for-in
, and for-each
—but which is fastest? I attempted to answer that question about three years ago, but the article is in dire need of a followup as many version of Flash Player have been released since then and the question is core to our everyday lives as AS3 programmers. So which type of loop is fastest in 2012?
Behind the scenes Array
holds its values in two ways: a densely-packed array at the beginning and a sparsely-packed map after that. This means it can be used as a map where the keys are indexes and not take up a huge amount of wasted space. Dictionary
can also have int
keys. Which is faster? Today we’ll find out!
This is an extremely common task: converting a Number
to an int
. There are a lot of ways to do it, but which is fastest in AS3? Today we’ll look at a performance test app that attempts to find the fastest way to accomplish this. The answer just may surprise you!
Today’s article is quick and to the point: when you need to take the base 10 logarithm of an integer you can speed this up by about 8x. Read on for the technique and save some CPU cycles!
Many programmers are aware of a special case where you can use a bitwise shift for multiplication or division when you’re multiplying or dividing by a power of two. For example, you can replace i * 2
with i << 1
and i / 2
with i >> 1
. A lesser-known trick works for modulus. But are these alternatives actually any faster? Today's article puts them to the test!
Math.abs
is a commonly-used utility function for taking the absolute value of a Number
. However, there’s no special-case version for taking the absolute value of an int
. Of course Math.abs
will work for int
values, but we can do it faster. Read on for a couple of ways.
A common programming task is to determine if an integer is even or odd. Recently, I saw an article showing how to do the task faster than the usual way: (i % 2) == 0
. Today’s article shows an even faster way to check for even or odd.
The most common way to obtain the geometry of a 3D model is from a file output from a modeling package like 3D Studio Max, Maya, or Blender, but it’s not the only way. In the case of simpler forms of geometry it is practical to generate it yourself using AS3 code. When you do this you eliminate the needed download and gain the flexibility to scale up or down the complexity of the model on a whim. Today’s article shows some AS3 code to generate spheres for all kinds of uses: planets in space simulators, placeholders for debugging physics simulations, and whatever else you can dream up.