Programming in AS3 invariably involves choosing between various collections: Array
, Vector
, Dictionary
, Object
, ByteArray
, and so on. What if you need to quickly copy between them? Your choice of collection could result in a 450x slowdown in your app… or a 450x speedup!
Posts Tagged vector
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?
It’s been a while since I’ve posted a utility function, but today I’m breaking the streak and posting a couple of related functions I frequently find useful in debugging: joinN
and joinNLabeled
. These functions are like Array.join
and Vector.join
, but they group elements of the array to make the resulting string much easier to read.
Which is the fastest way to store data: Vector
or ByteArray
? Given that you can upload both types to Stage3D
in Flash Player 11, this question has never been more relevant. So which should you use to maximize your app’s speed? Read on for the performance testing.
The site has had many articles about improving the performance of your app, but never discussed the basic methodology on which all optimizations should be based. Today’s article will go over a scientific approach to optimizing that makes use of a tool known as a profiler and demonstrate using an AS3 application just why it’s so important to usage such a tool.
Today’s article is about an unintuitive-yet-simple optimization you can use to hugely increase the speed of reading from Array
, Vector
, Dictionary
, Object
, and dynamic
classes. Need I say more? Read on for this amazing speedup!
During some recent memory profiling I was reacquainted with just how many ways there are to unknowingly allocate an object in AS3. The problem is seldom the allocation itself, but rather the later garbage collection (GC) to delete those objects. Ever used a Flash profiler only to see a huge chunk of your CPU time going to [reap]
, [mark]
, or [sweep]
? Yeah, that’s the GC at work. Today’s article talks about some of the ways you end up allocating objects in AS3 without using the new
keyword. These subtle errors can end up costing you!
The Vector3D
class debuted in Flash Player 10.0 as Adobe’s official implementation of, well, a 3D mathematical vector (not the pseudo-Array
class Vector
). Weirdly, it has a w
component and is therefore technically a 4D vector, but its API inconsistently make use of the fourth dimension. There are also strange oversights, inefficiencies, and functionality it really should have always had. Read on for my custom Vector3D
derivative—Vector3DExt
—that fixes all of these problems by extending and improving on the original.
AS3 has two integer types: int
and uint
. In my experience, most AS3 programmers just use int
everywhere and ignore uint
. This is usually acceptable as the need for unsigned integers is rare compared to their signed counterparts. However, there are significant performance differences between the two. Read on for the impact of uint
on your loops. The original version of this article’s performance test contained a small-but-critical error that led to a lot of incorrect analysis and results. This version of the article has been corrected.
When you construct an Array
or a Vector
, you can specify an initial size. Why would you do this?There are various reasons you may want to reserve initially-unused slots for logic reasons, but are there any performance gains to be had by pre-allocating this space for an Array
or Vector
you intend to completely fill right away? Today I’ll take a look to see just how much performance can be gained by pre-allocating Arrays
and Vectors
.