Today’s article expands on the previous loop test article to find out which kind of loop is truly fastest. Read on to find out!
Posts Tagged performance
Sometimes a tiny amount of code costs a huge amount of performance. This is especially true of built-in language features, which many programmers assume to be extremely cheap if not free. Today we’ll look at
if and see just how much performance it can cost your app. Read on to see!
While little utilized, C#’s
struct type can come in really handy sometimes. Today’s article shows how to use it to get a lot more mileage out of modern CPUs’ caches to really boost your app’s performance. Read on for some quick tips!
As we know, foreach loops create garbage when used with a
List<T>. This happens the first time you iterate over one and it happens every time thereafter. A comment on that article shared a link to a class called
FastList that was written expressly to solve the GC issue. Does it? How does its performance compare to plain old
List? Today’s article puts it to the test to find out!
One typical piece of advice for dealing with the slowness of Unity’s garbage collector is to periodically force a garbage collection, such as every 30 frames. Even Unity advises this. The idea is that you’ll spread out the garbage collection work across many frames rather than having a big spike that causes your frame rate to stutter. But the question remains- what’s the best rate to force the GC? Today’s article tries out various intervals to see which is best. Read on for the results!
Having just concluded the series on handling errors without using exceptions, now’s a good time to check up on an assertion I made in the first part: exceptions are slow. A good question to ask is “compared to what?” So let’s put them up against good old error codes and the new
Either type I presented in the series. Which is fastest when there is no error? Which is fastest when there is an error? Read on to find out!
Unity programmers have their choice of two kinds of events. We could use the built-in C#
event keyword or Unity’s
UnityEvent classes. Which is faster? Which one creates more garbage? Today’s article finds out!
In reading others’ C# code I consistently see some programmers call delegates like a function—
del()—and others use the
Invoke method of the
del.Invoke(). Is there any difference between the two? Is one better than the other? Today’s article finds out!
It’s easy to forget about
struct in C#. After all, it’s not available in other languages like Java or AS3 and it seems to have fewer features than good old
struct can really help you out when it comes to garbage creation! Today’s article discusses some strategies to get the most out of
struct. Read on to learn how to use structs to put a stop to that pesky garbage collector!
We know that we should reduce the garbage our code produces to lighten the load on Unity’s garbage collector. The trouble is that many of the ways we’re creating garbage are hidden from us. One such way to inadvertently create a lot of garbage is to use a
foreach loop… at least that’s what we’ve been told. Do
foreach loops really create garbage for all types of arrays, lists, dictionaries, and the rest of the collections? Do they create garbage for every loop or just the first one? Today’s article investigates to put these questions to rest. Are you safe using
foreach loops or should you re-write everything to use
for. Read on to find out!