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!
Posts Tagged array
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!
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.
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.
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.
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.
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.
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!
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!