-
Notifications
You must be signed in to change notification settings - Fork 0
Performance
EnTT is mostly templates, and templates come at a cost to compile time. The following is various considerations to make when working with EnTT with regards to keeping compile time in check.
Table of contents
- Strive towards 0 templates
- Each template instantiation costs 200 ms
- Prefer
for
toeach
- Prefer Single-Component Views
An unreachable goal, as EnTT is almost entirely made up of templates. But something to strive for. If you are in a position to either call a template or not, don't.
Tune your mind to this number. It may not seem like a single template could cause such strain, but internally, an EnTT template calls on other templates, which in turn calls on other templates. A translation unit with 40 calls can expand into 2,000+ template instantiation, adding 10 seconds or more to your compile time.
A call to each
implies several additional template instantiations, as each
is a template which calls on other templates. If you can, prefer doing this
// Yes
for (auto entity : registry.view<A>()) {
// Do something with `entity`
}
// No
registry.view<A>().each([](auto entity, const auto&) {
// Do something with `entity`
});
Whenever you ask for more than one component in a view, a separate template expansion party ensues.
EnTT - Fast and Reliable ECS (Entity Component System)
Table of contents
Examples
Blog
- RAII
- Polymorphism
- Shared Components
- Intent System
- Input Handling
- Undo
- Operator Stack
- State
- Resources
- Interpolation
Resources
Extras