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 - Pastebin.com
The BP code: blueprintUE | PasteBin For Unreal Engine 4 (or screenshot: Screenshot - 796f5bd27370a839011630b4dc8454ba - Gyazo)
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.