Reputation: 16711
What is the best way to evaluate exact minimal value of -fconstexpr-steps=
and -ftemplate-depth=
parametres required for compilation of a program?
What I do currently is a bisection of a value. But for real-world template-loaded programs it became very long operation, even being logarithmic on upper limit of a value.
There is -v
option and -ftime-report
, but even their output not gives any desired information about maximum template depth actually used and number of steps actually passed during evaluation of constant expressions.
Upvotes: 12
Views: 160
Reputation: 70516
You could look at how Boost.Hana does its benchmarking. Its benchmark code is written mostly in the form of eRuby templates. The templates are used to generate C++ files which are then compiled while gathering compilation and execution statistics.
Bisection to find the necessary values of -ftemplate-depth
and -fconstexpr-steps
is of course a bit cumbersome to do by hand, but you could also write a script (Ruby, Python, whatever floats your boat) to automate this. Just double the initial value in a simple while
loop until the program compiles successfully.
Upvotes: 3