Posts Tagged performance

StrangeIoC Reflection Performance

StrangeIoC is a library that can help you build your Unity app with a “pure code” approach. Today’s article addresses one common concern with using StrangeIoC- it uses a lot of reflection. As we know, that’s really slow in Unity. StrangeIoC tries to work around it by letting you control when the reflection takes place so you can put it on a loading screen or some other convenient place. Today’s article finds out just how slow the reflection is to determine if this is really a valid reason to not use StrangeIoC (or other dependency injection frameworks). Read on to find out!

Read the rest of this entry »

Tags: , , ,

No Comments

Linked Lists Are Slow

Contrary to what you may have learned in a data structures class, linked lists are virtually always slower than just using arrays. The same goes for array wrapper classes like List. Today’s article discusses why this is the case and tests it out with a C# Unity app to make sure that the real world validates the theory.

Read the rest of this entry »

Tags: , , ,

2 Comments

Optimizing Arrays and Lists

Last week’s article compared the performance of arrays with List<T> and found List lacking. This week we’ll optimize both List and array to maximize performance regardless of which you choose to use.

Read the rest of this entry »

Tags: , , , ,

1 Comment

Array vs. List Performance

System.Collections.List<T> is used everywhere in C# code. Except for very special cases, it’s the replacement for arrays, linked lists, queues, and most other one-dimensional data structures. This is because it has all kinds of extra functionality, including the ability to grow in size on-demand. Today’s article wonders about how much performance is lost to gain this convenience and tests the List<T> class against the lowly C# array: T[]. How much performance are you giving up with List and why is that happening? Read on to find out!

Read the rest of this entry »

Tags: , ,

6 Comments

Virtual Function Performance

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?

Read the rest of this entry »

Tags: , , , ,

1 Comment

String.Format() vs. Concatenation vs. String Builder

What’s the fastest way to build a string in C#? We have several options available to us. string.Format() is a function built right in to the string class., Concatenation ("a" + "b") is a feature of the language itself! The System.Text.StringBuilder class is a built in class with a name that makes it sound like it’s purpose-built for building strings. Today I pit these three against each other to find out just which one you should be using to build strings as quickly as possible.

Read the rest of this entry »

Tags: , , , ,

9 Comments

IL2CPP Slowdown (Partially Solved)

The new IL2CPP scripting backend in Unity 4.6.2 and 5.0 is supposed to be much faster than the old Mono backend. I ran some benchmarks, but mostly found slowdowns compared to Mono. Today’s article shows the tests I ran, the results I got, and wonders why the IL2CPP version seems so slow. Perhaps one of you, dear readers, knows the reason why. Update: Part of the reason why has been discovered. Read on for updated results.

Read the rest of this entry »

Tags: , ,

3 Comments

Unity Function Performance

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!

Read the rest of this entry »

Tags: , , , , ,

1 Comment

Basic LINQ Performance

SQL-style LINQ queries are a concise, readable way of performing various tasks dealing with all kinds of collections. Surely all that convenience comes with a performance cost to it. How bad do you think it is? Today we’ll look at the cost of some basic LINQ queries (Where, Select) versus the equivalent non-LINQ code. We’ll also see how much slower both of them are compared to manually-written, traditional code that does away with all the flexibility. Read on to see the results!

Read the rest of this entry »

Tags: , , , ,

2 Comments

Unity Coroutine Performance

Unity’s coroutine support allows you to easily create pseudo-threads and write synchronous-looking code that doesn’t block the rest of the app. They can be very handy for a variety of tasks. Before using them, we should understand the performance cost. Today’s article takes a look at the cost of starting a coroutine as well as the cost of running it. Just how expensive are they? Read on to find out!

Read the rest of this entry »

Tags: , ,

3 Comments