Constexpr function that returns ticks at compile time for profiling?

I want to have a measure of the time it takes to execute a specific compile-time function at compile time. for example

constexpr int64_t triangle_sum(int64_t n) {
   int64_t s = 1;
   for(int64_t i = 1; i < n; i++)
      s += i;
   return s;
}

      

I'm looking for a function constexpr

that returns different values ​​on each call: it should return the time inside the compilation process, or the current time of day or something similar. So that I can measure and compare the "compile time" of different compile time algorithms.

+3


source to share





All Articles