Instrumenting a program for timing

Is there a standard method of instrumenting a program so it will optionally display the CPU time for one or more phases? I'd like to do that for TableGen.

Clang has something like that with the -ftime-trace option. This appears
to make use of the llvm::TimeTraceScope class.
--paulr

Thanks, I'll check that out.