Narek
Narek

Reputation: 39871

Unity - does the current version generate native code or not?

Here I can see that Unity documentation says that it is 50% slower than native code: http://docs.unity3d.com/412/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html

Here it says that there is an IL2CPP compiler, that obtains c++ code which is compiled into native code. So is it now creating native code, or is it 50% slower? :) http://blogs.unity3d.com/2015/05/06/an-introduction-to-ilcpp-internals/ http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity/

Upvotes: 6

Views: 1533

Answers (1)

Josh Peterson
Josh Peterson

Reputation: 2329

The documentation from Unity you referenced is pretty old, and even at the time it is written, I would really wonder about those performance numbers. In general, performance is much more complex to measure and report than one number like 50% can express.

If you want to learn more about IL2CPP, check out this blog post series.

Based on our benchmarks at Unity, we're seeing better performance for script-bound code with IL2CPP than with the Unity version of Mono. You can find one benchmark we have published here.

There are a few caveats to keep in mind though:

  • Unity uses an old version of the Mono runtime (circa 2011). Newer versions are better - and we are working on upgrading the runtime now.
  • Most game code is not script-bound, it is usually GPU-bound.
  • The generated C++ code is still providing the safety of a managed language, so it makes array bounds checks, for example.
  • The performance difference between the Mono AOT and the IL2CPP compilers will vary based on the platform. On some platforms, the Mono AOT compiler produces machine code as well as a C++ compiler. On other platforms this is not the case.

Upvotes: 9

Related Questions