Today’s article is the first to test Unity script performance speed. It establishes a way to set up and test C# scripts in Unity whether you have access to Pro or not. As a first example, I was reminded by the news this week that AddComponent(string)
is being removed in Unity 5.0. These alternative versions of AddComponent
and GetComponent
aren’t something I normally use, but the news got me thinking of their performance compared to the generic-typed versions: GetComponent<ComponentType>()
. The docs say to avoid the versions taking a string
, but how bad could the performance really be? Today’s article puts the two versions to the test to find out just that!
Posts Tagged type
Many modern strongly-typed languages have introduced a way for you to not have to type a variable’s type. In C#, you can use var
instead of the actual type. In C++, you use auto
. AS3 has a similar feature with it’s “untyped” type: *
. In those other languages, var
and auto
are syntax sugar that the compiler replaces with the actual type. Will the AS3 compiler and/or Flash Player do the same for us? Today’s article finds out if it’s safe to skip the type and just use *
.
If you’re thinking “I know what an int
is”, you need to take this little quiz to find out for sure!
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.
Five months ago I said I’d talked about explicit type conversion. I hadn’t, really. What I talked about before was type casts. A cast changes the type, not the data. Today, I’m actually going to talk about type conversion and show you the costs of converting between all of your favorite types: int
, uint
, Number
, Boolean
, String
, and even XML
.
Today’s article is a followup to an article (Cast Speed, itself a followup to Two Types of Casts) from September that continues to gather comments. Sharp-eyed reader fastas3 brought up a good point that warranted some further investigation into the topic. So today we’ll be taking yet-another look at typecasting in AS3 to try to unravel some of its strange mysteries.
I’ve talked before about explicit type conversion and used the function-call style (Type(obj)
) and the as
keyword to accomplish the task. Today, I’m going to talk about implicit type conversion and use—as implicit would imply—no operators at all!
Today’s article is in response to some interesting comments on the previous article comparing Array‘s performance to that of Vector. Today I’ll test different types of Vectors and the performance of deleting elements.
When an object is converted to a String, it is first checked for a toString() method. But there are subtleties to this that you may not have considered.
Usually languages just have one way to specify “no value”. Call it null or nil or whatever you’d like, but AS3 and JavaScript have two: null and undefined. Here’s a little bit to help you understand when and why you’ll come across the two as well as some tricky differences between them.