By request, today’s article follows up on my Unity Function Performance article from a year and a half ago using Unity 5.0. It adds on GameObject.SendMessage
and virtual
functions to get a more complete picture of how various function calls in Unity perform. Of course it runs these tests using Unity 5.4 to see if there have been any changes in the engine. Read on for the results!
Posts Tagged function
Iterator functions and their ability to yield return
values then continue on really come in handy for a variety of situations. Unfortunately, they come with some pretty serious performance and garbage creation drawbacks. So today’s article explores alternatives in various forms of callbacks: delegates, interfaces, and classes. Can they perform better than iterator functions? Can they avoid garbage creation? Read on to find out!
One type of function was left out of Unity Function Performance: virtual functions. Functions in C# are non-virtual by default and you have to explicitly use the virtual
and override
keywords to override them. Why not make this the default, like in AS3 or Java? Are virtual functions that much slower? Today’s article finds out! Should you be worried every time you make a function virtual
?
Which is the fastest kind of C# function in Unity? There are several to choose from: regular old instance methods, static methods, delegates, and lambdas. Is there any performance reason to choose one over the other? Today’s article answers just these questions by putting each type of function to the test. Read on to see which is fastest and which is slowest!
Two of C#’s really interesting features are technically operators, but didn’t fit in last week’s article. These are both ways to create anonymous functions: lambdas and delegates. AS3 has anonymous functions too, but today’s article will discuss how they differ from the C# approaches. Read on to learn how to harness the power of anonymous functions in C#.
Continuing from last time, this article begins covering features of C# classes that aren’t in AS3. We’ll begin with abstract classes and functions, which AS3 required workaround code to enforce even at run-time. Today’s article shows you how to use C# to cleanly enforce these at compile-time.
This article is for the AS3 developer who’s decided to switch to Unity and doesn’t know the first thing about programming in C#. It’ll walk you through the basics of C# to get you oriented and productive.
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!
Above all others, there is one article I refer back to most: 2009’s Function Performance. It was updated for Flash Player 10.1 and 10.2, but not 10.3, 11.0, 11.1, or 11.2. Today I’m updating this article for Flash Player 11.2, adding some missing function types, and including a set of graphs to make for the ultimate function performance reference.
The const
and final
keywords only apply at compile time. Despite having written about const and final before, readers frequently ask me about these two keywords. Today’s article will answer the question and definitively show that these keywords only apply at compile time: not runtime. UPDATE: const
is still just a variable as far as performance goes, but its protections do extend to runtime.