Hi Akim, > Would there be some interest for this in gnulib?
There is well a place for modules like this one in gnulib. See https://www.gnu.org/software/gnulib/manual/html_node/Portability-and-Application-Code.html > allow self-profiling. It does not aim at replacing real profiling > tools, but rather to report in a concise way the cost of various > phases in a program. The documentation of this module should, IMO, state the advantages and disadvantages of this module compared to "real" profiling tools. The comparison points I can see (surely I missed some) are: Upsides: * 'timevar' is portable. You can use it to evaluate performance issues on platforms for which no profiler exists or for which you don't want to install and configure one. * 'timevar' can be useful for remote troubleshooting when the person who has the issues does not have developer skills. Downsides: * In my experience, when profiling, most often the result is unexpected. Whereas the 'timevar' module provides no insights of new kinds. It can only provide insights along the "phase" definitions that were already made ahead of time. > Of course I > guess there’s work to do for it to be accepted (doc, style, etc.), Two suggestions: 1) Simplify. I don't see the point of the DEFTIMEVAR layer with the enum. Couldn't the code just do timevar_t tv_total; timevar_t tv_reader; .. and init_timevar (); timevar_start (&tv_total); timevar_push (&tv_reader); reader (); timevar_pop (&tv_reader); 2) Convert from K&R C to ANSI C. Bruno