It’s been over three years since the last article on LINQ performance. That was all the way back in the Unity 5.0 days using Mono as a scripting backend. Today we’ll update that article’s test with Unity 2018.1 and IL2CPP to see how LINQ fares these days. Is it any better? Read on to find out!
Posts Tagged array
There are many permutations of loops we can write, but what do they compile to? We should know the consequences of using an array versus a
Length, and other factors. So today’s article dives into the C++ code that IL2CPP outputs when we write these various types of loops to examine the differences. We’ll even go further and look at the ARM assembly that the C++ compiles to and really find out how much overhead our choices are costing us.
C++ doesn’t have a
foreach keyword, but it does have an equivalent in “range
for loops”. Today we’ll implement support for them so we can easily loop over arrays and types implementing
The last time we looked at performance was way back in part four of the series. Ever since then we’ve been relentlessly adding more and more features to the C++ scripting system. So today we’ll take a break from feature additions to improve the system’s performance in a couple of key areas.
The series continues by adding support for a major feature: arrays. These are used very frequently throughout the Unity and .NET APIs and the lack of support for them has been a big missing piece of the puzzle for most games. The GitHub project has been updated to support single- and multi-dimensional arrays. Read on to learn how this support was implemented!
Every time I see
for (var i = 0; i < array.Length; ++i) I wonder if accessing that
Length property is slow. Should I cache it? It's comforting to know that
for (int i = 0, len = array.Length; i < len; ++i) is only dealing with local variables except on the first loop. Local variables must be faster, right? Likewise, I wonder the same thing about
List<T>.Count. I finally got around to running a test to see if caching these length properties makes any performance difference. The answers might surprise you!
We’re nearing the end of the series to build a no-garbage replacement for
System.Linq. Today we tackle functions that work on already-sorted ranges and functions that work on ranges that are in heap order. These include common set operations like “union” and “intersection”. Read on to see how to use them and for the updated library that you can use to eliminate your garbage creation!