Unity Benchmarking

The entity component system in a c++ fashion wasn’t a huge challenge but it was more of a huge tasks as I wanted to test for many different systems that the inheritance engine contained. These systems were physics, translation, rotation, rendering etc. Importing different libraries was also a big issues especially with version control. Every time I added it to the github to make it public a lot of the dependencies would reset.

I decided to therefore delve myself into a smaller scope for the project by creating an entity component system within unity that is very fast and efficient. I did not know what to expect at first but the results were really impressive. I did manage to run into some profiling issues as there was a specific category that stopped myself from being able to test correctly. Apparently in Unity there was a set vsync option that sets the frames to your monitors refresh rate which for me was at around 75hz. It was in a weird location and I expected it to be in project or player settings. However there is an option under aspect ratio where you can turn vsync off which in the end does kind of make sense.

After all the trouble shooting was done I created a system for both inheritance and ecs. Did some benchmarks and here are some of the results:

When comparing results they both climb at steady rate with no mayor peaks and spikes. However inheritances climbs at a much steeper rate and it seems like the processor has to do a lot more work in order to render those entities. The time each thread takes to process for ECS differs at around 0.1 – 0.2ms per 1000 entities which is a lot better than inheritance. It is a lot heavier in this case for the processor to run a non ECS setup and it literally increased the RPMs of the computer showing that the CPU was under quite some heavy loads.

The next benchmark was to show the amount of frames per entities drawn. What was interesting about these results is that inheritance actually started of a lot stronger than the entity component system with just one entity. It shows that ECS purpose is to be used to render, process and work with over a thousand entities which is something it does best at. A single entity of the same type is going to run very well with inheritance which in this case should probably be a player character. You can see that the frames drop from 2000 to about 500 a second going from 1 entity to a thousand. The entity component system has a much more steady rate which ultimately makes it lead over inheritance. It is also very convincing to see the steady decline because it means it runs efficiently even with over 10000 entities. I am sure you can run double the amount of entities and still have enough frames for the game to be playable.

Overall I was very happy with the performance of both systems because it gives me a much better insight of what the purpose for both design patterns are. Each have their areas of where they can be most effective and it shows that not one of them cancels out completely the purpose of another. An entity component system should be a common practise among all engines and games that run over thousands of entities seen in virtual reality and real time strategy games. Here are the final benchmarks displayed in unity for the entity component system.

Add a Comment

Your email address will not be published. Required fields are marked *