ZeroK-RTS / Zero-K

Open source RTS game running on the Spring/Recoil engine
https://zero-k.info
GNU General Public License v2.0
687 stars 205 forks source link

Re-measure IterableMap #5055

Open sprunk opened 11 months ago

sprunk commented 11 months ago

Recent engines offer better tracing/profiling tools (Tracy) and Beherith claims that pairs(map) is faster than even the IterableMap.GetBarbarianData interface). Perhaps worth repeating whatever measurements had originally been made, or just measure existing use cases of iterable map, because if it's faster to just use pairs then most uses of iterable map can be thrown out (simplicity is king).

It does offer some nice features (constant-time count, random element, staggered iteration) so it shouldn't be completely removed though.

sprunk commented 9 months ago

Old measurement #4132

GoogleFrog commented 9 months ago

The neat thing about iterable map is the internals can be modified to be whatever is fastest, and a lot of stuff will automatically update. The barbarian stuff would be annoying though, but mostly routine.

sprunk commented 9 months ago

Well if measurements confirm that pairs is the fastest then I'm not sure if it's worth having because that is also what's already the most idiomatic. Same way you wouldn't have AddNumbers(x, y) with customizable internals if it turned out that x + y is faster than whatever complex bit hax microoptimisation one could come up with, because that just makes working with code harder.

Though this is just an elegance thing, people can ignore the existence of IterableMap and use pairs regardless with no ill consequences.

GoogleFrog commented 9 months ago

Apply and ApplyFraction are nice.