Hi! Bison has adopted, many years ago, timevars, a set of tools that 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. For instance with Bison:
Execution times (seconds) LALR(1) : 0.01 ( 3%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall IELR(1) Phase 4 : 0.01 ( 3%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall outputing parser : 0.01 ( 3%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall running m4 : 0.31 (89%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall freeing : 0.01 ( 3%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall TOTAL : 0.35 0.01 0.00 timevar was stolen from GCC. When it was introduced in Bison, the times were significantly larger, there were less zeros in the table :) (real zeros are not displayed, there are more phases which are measured). Would there be some interest for this in gnulib? Of course I guess there’s work to do for it to be accepted (doc, style, etc.), but before going that way, I’d like to know where it makes sense. Here’s how it’s used in Bison: timevar_report = trace_flag & trace_time; init_timevar (); timevar_start (TV_TOTAL); timevar_push (TV_READER); reader (); timevar_pop (TV_READER); timevar_push (TV_REDUCE); reduce_grammar (); timevar_pop (TV_REDUCE); timevar_push (TV_SETS); derives_compute (); nullable_compute (); timevar_pop (TV_SETS); […] (Note that phases can be nested: TV_TOTAL includes all the others). Attached, the current state of the timevar files in Bison.
timevar.c
Description: Binary data
timevar.def
Description: Binary data
timevar.h
Description: Binary data
timevar.m4
Description: Binary data