Category Archives: Benchmark

Benchmarking dynamic method invocation in .Net

Benchmarking method execution through interface, base class, virtual, override, dynamic, reflection and expression trees. In .Net there are many ways to execute a method. The fastest being the straight forward call to a static method. But how does its speed compare to other methods? There are countless reasons why we sometimes can’t just make a direct call. We… Read More »

sizeof() vs Marshal.SizeOf()

To get the size of a data type in .Net you can use sizeof()  or Marshal.SizeOf() . I’ll briefly explain the difference between the two. sizeof() sizeof()  (MSDN) can only be used on data types that have a known size at compile-time. It is compiled as a constant. If you attempt to use it on invalid data types you… Read More »

Speeding up Unitys Vector in lists/dictionaries

Introduction With this post I am digging into some performance improvements for Unity 3D’s Vector2, Vector3, Vector4 and Quaternion. The short version is that they really need IEquatable<T>  and can benefit from a better GetHashCode() . I’m demonstrating this with example of how it severely decreased performance in my project. Adding IEquatable<T> has no side-effects, if is actually best… Read More »