Debugging a performance issue, do I commit the timing code?

I am working in a small company and I am flattered to serve as the SED Lead of a group of 5. We are developing a C++ application. One requirement is that it needs to run fast. Today, I noticed one function, say f1(), and its callees, are slow for some input. To quantitfy how slow it was, I added code auto t1 = std::chrono::high_resolution_clock::now() around the function call to measure its execution time. Then, I revised f1(), and the execution time reduced by half, which proves my revision is good. As a result, I committed my revision to the slow function. Now the question is, how do I deal with the added code that measures the execution time of the function? Do I commit it? We don't need to output the time every time for debug version or release version. If I don't commit it, other SED who reviews my code has to add back the performance measuring code to his local copy to test my revision. Do I guard the performance measuring code with conditional compilation or something like a command line flag? Admittedly today we are focusing on f1(), but next sprint we may check another function f2(), do we guard timing code with the same flag?

Mar 17, 2025 - 12:34
 0
Debugging a performance issue, do I commit the timing code?

I am working in a small company and I am flattered to serve as the SED Lead of a group of 5.

We are developing a C++ application. One requirement is that it needs to run fast.

Today, I noticed one function, say f1(), and its callees, are slow for some input. To quantitfy how slow it was, I added code auto t1 = std::chrono::high_resolution_clock::now() around the function call to measure its execution time.

Then, I revised f1(), and the execution time reduced by half, which proves my revision is good. As a result, I committed my revision to the slow function.

Now the question is, how do I deal with the added code that measures the execution time of the function? Do I commit it? We don't need to output the time every time for debug version or release version.

If I don't commit it, other SED who reviews my code has to add back the performance measuring code to his local copy to test my revision.

Do I guard the performance measuring code with conditional compilation or something like a command line flag? Admittedly today we are focusing on f1(), but next sprint we may check another function f2(), do we guard timing code with the same flag?