C++ and Blueprints speed comparison

I haven’t found any reliable benchmarks about comparison execution speed of C++ and Blueprint versions of the same code. So I made my own.

Aims and solutions:

  • Speed comparison of language operations. I see no idea of testing some calls to the same engine functions that will execute the same code in both cases. So I made two versions of a method with cycles, assigning values, function calls, assigning array values and getting values from arrays.
  • A fair test. So no redundant optimizations, no redundant bonuses from branch prediction and so on.
  • The same method to calculate time. So I made two Blueprint Function Libraries: one implemented in C++ and another in Blueprints. Both called from blueprints. Two calls for each function (1-2-1-2) to see if there was some external load factors. Execution time calculated in Blueprints in milliseconds.

The C++ code: UE4 Lib Benchmark -
The BP code: blueprintUE | PasteBin For Unreal Engine 4 (or screenshot:
The complete project: Pavel Grebnev / ue4-benchmark · GitLab

Average results of few runs Windows 64 bit version (InNumTimes = 100000):
Without nativization
BP ~4950ms
C++ ~180ms
Blueprint version of the function is 27.5 slower than C++ one.

With nativization
BP ~300ms
C++ ~180ms
Blueprint version of the function is 1.6 slower than C++. And that’s really cool.

It’s important to clarify here:
This data got from testing only one function so:

  • If I made another function to test then I probably got some other time values.
  • Real game execution will obviously spend more time in engine code than in your calculations. So results of my test don’t mean that game made fully in blueprints will be 27 times slower than C++ version of that game. It just means that it still isn’t a good idea to do heavy calculations (e.g. physics calculations) only in Blueprints.
  • My BP code can contain some bottleneck whose optimization can made it much faster.

I’m not pretending to fully answer the question “How much is Blueprints slower than C++?” because answer always depends on use cases. But I want to make a fair test to get closer to that answer.

This test was made on UE 4.15.2, I’ll update it sometimes when new versions come (a version on UE 4.16 will come soon). Also I will be glad to hear if you find some problems with the test or suggest some improvements.

This is known since the UDK/Kismet days…

Thanks for this, i was really interested in this c++ vs BP speed

Just updated the project to UE 4.16. Got pretty the same results.

Average results of few runs Windows 64 bit Shipping version (InNumTimes = 100000):
Without nativization
BP ~4865ms
C++ ~180ms
Blueprint version of the function is 27 times slower than C++ version.

With nativization
BP ~302ms
C++ ~180ms
Blueprint version of the function is ~1.7 times slower than C++ version with nativization enabled.

Is nativization on by default?

Thanks for the info and the examples

That’s pretty cool to know, thanks !

No, but you can enable it in project settings: Nativizing Blueprints | Unreal Engine Documentation

Sometimes something can’t be nativized:

  • some new features (e.g. in 4.15 was added ability to create Maps and Sets in blueprints, but if you use these features with nativization enabled you can’t package your project),
  • some other things that may be haven’t tested yet by Epics with nativization enabled.
    But for big BP projects (especially mobile and VR projects) it seems like a good idea to enable nativization and just not to use things that can’t be nativized.

Thanks man! finally found an reliable and accurate article. search all around the internet for this but never found the answer good to know the forum is such a great place.