Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Benchmarking compile-time properties of a program

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.

like image 459
Tomilov Anatoliy Avatar asked Dec 14 '15 07:12

Tomilov Anatoliy


1 Answers

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.

like image 72
TemplateRex Avatar answered Nov 03 '22 09:11

TemplateRex