- Home /
System or Unity Action?
In terms of performance which one is the best?
Answer by JVene · Jul 25, 2018 at 10:40 PM
Where performance is paramount, System hints at being more native with the potential of being faster, but there are many caveats.
C# implemented on Windows is likely to use Microsoft's framework. On other platforms where .NET isn't native, it may be Mono. There could be a performance difference on similar hardware.
If Unity offers a counterpart, it is likely going to be a wrapper for System on Windows. The compiler's optimizations should elide the wrapper, rendering it a zero impact and therefore the same. However, Unity would choose to offer a counterpart for portability reasons, because the underlying C# compilers on various platforms may differ, which prompted the designers to provide a Unity counterpart rather than merely assume System should have been used.
The choice for portability is, therefore, informed by the platform choices you intend to support when compared to your interest in performance.
Where portability is paramount, the performance question become secondary, favoring the Unity counterpart. Where performance is paramount, portability may suffer.
When one can't choose, experiment is required to know if the author should bother with conditional compilation pragmas so the code can be directed to whichever is best on each particular platform.