sourencho / ungroup_game

A multiplayer game about temporary alliances written with a custom engine in C++ and SFML
14 stars 1 forks source link

TemporalMetric very inefficient #169

Closed sourencho closed 4 years ago

sourencho commented 4 years ago

Did some profiling with gperftools and found that TemporalMetric::getRate and TemporalMetric::getAverage are using a lot of CPU.

Client running with those calls runs at 30% CPU Client running without runs at 99% CPU

Probably because of the way TemporalMetric::getAllCounts is flattening the vector of vectors. https://github.com/SourenP/ungroup_game/blob/0aa9da74245c0fd0f2298a7cfd475a54997e204b/src/common/metrics/TemporalMetric.cpp#L46-L52

sourencho commented 4 years ago

We can just return an iterator instead of creating a new flattened vector