Posts Tagged array

From AS3 to C#, Part 18: Resource Allocation and Cleanup

Tags: , , , , ,

Today we continue the series by looking at how resources—primarily memory—are acquired and cleaned up in C#. We’ll go way beyond the new operator and discuss advanced features like finalizers and using blocks that can make releasing resources much less prone to errors. Read on to learn!

Read the rest of this article »

No Comments

Faster Functional Methods for Array and Vector

Tags: , , , , ,

Four years ago I tested the functional programming-style methods of Array and Vector: every, filter, forEach, map, and some. In that article I showed that these functions are much slower than doing the same task through traditional loops. Today’s article seeks to improve the performance of the functional methods while retaining readability by using ASC 2.0’s [Inline] metadata. Can homemade versions of these functions beat the built-in ones from Adobe? Read on to find out!

Read the rest of this article »

No Comments

When getSize() Lies

Tags: , , , , , , , , , , ,

flash.sampler.getSize() is a handy tool for figuring out how much memory a class instance uses. However, it is often flat-out wrong. Today’s article tries it out on a variety of classes to find out which ones it works on and which ones it doesn’t.

Read the rest of this article »

4 Comments

Optimize Algorithms and Data Structures First

Tags: , , , ,

Today’s article is both a reminder to optimize your algorithms and data structures before your code and a demonstration of the payoff you’ll get by doing so. By choosing the most effective algorithm and data structure to solve your problem you’ll reap huge rewards in performance. A 10x, 100x, or even bigger boost is easily attainable.

Read the rest of this article »

No Comments

Int Keys: Object vs. Dictionary vs. Array vs. Vector

Tags: , , , , , , , ,

Given that Object and Dictionary can have int keys and that int keys are faster than String keys, a natural performance test follows: which class is fastest at reading from and writing to those int keys? Is there a difference between the four Vector classes? Today’s article performs just that test and comes up with the answers.

Read the rest of this article »

8 Comments

The Four Vector Classes

Tags: , , , , , , , ,

There are four Vector classes in AS3. It seems like there is only one—Vector—and that it supports generics, but that is only an illusion. Today’s article will do some tests to reveal the implications to your app’s correctness and efficiency.

Read the rest of this article »

3 Comments

If-Else Trees vs. Array and Vector

Tags: , , , , , ,

We’ve seen that if-else trees are way faster than Object, Dictionary, and even switch at key-value mapping, but how do they stack up against Array and Vector? Today’s article puts them to the test and uncovers some unexpected results.

Read the rest of this article »

8 Comments

450x Speed Up Copying Between Collections

Tags: , , , , ,

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!

Read the rest of this article »

7 Comments

Loop Speed Redux

Tags: , , , , , , , , , ,

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?

Read the rest of this article »

15 Comments

Maps With Int Keys: Array vs. Dictionary

Tags: , , , , , ,

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!

Read the rest of this article »

7 Comments