klogg icon indicating copy to clipboard operation
klogg copied to clipboard

fix: optimize using constexpr and templates

Open GermanAizek opened this issue 2 years ago • 3 comments

@variar, I'm not sure of course, but maybe you're interested in rewriting some parameters of functions to create guaranteed C++17 metafunctions that are more optimized due to constant conditions and variables. I doubt that the functions I fixed have a big impact on performance, but this is a step towards using such a method for functions that are frequently called.

More info here: https://stackoverflow.com/a/57211067 My tests on godbolt here: https://godbolt.org/z/4qq9n38Tz

GermanAizek avatar May 07 '23 23:05 GermanAizek

As far as I understand, this removes a branch from code path at the expense of compiling separate versions of the function for different conditions. The approach might be useful. However, I'd apply it only for hot-path and after doing some measurements that justify increase in complexity/compilation time.

variar avatar May 13 '23 18:05 variar

@variar, should I run benchmark using std::chrono?

GermanAizek avatar Aug 02 '23 15:08 GermanAizek

@variar, is this pull request still relevant?

GermanAizek avatar Dec 13 '23 16:12 GermanAizek