Mercurial > gnulib
view doc/timevar.texi @ 40193:5fd32d128129
relocatable-prog: Use wrapper-free installation also on Mac OS X.
Reported by Paul Smith <psmith@gnu.org>.
* build-aux/install-reloc: Accept a 'mode' argument as first argument.
(func_relativize): New function, from gnulib-tool.
Handle mode 'macosx' through invocations of 'otool' and
'install_name_tool'.
* m4/relocatable.m4 (gl_RELOCATABLE_BODY): Determine use_macos_tools.
If use_macos_tools is true, set INSTALL_PROGRAM_ENV to an
'install-reloc' invocation with mode 'macosx'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 23 Feb 2019 22:42:54 +0100 |
parents | eaceb00fc84b |
children |
line wrap: on
line source
@node Profiling of program phases @section Profiling of program phases The module @samp{timevar} provides a simple self-profiling facility, based on timers. @smallexample Execution times (seconds) read : 0.09 (19%) usr 0.08 (80%) sys 0.09 (18%) wall read: scan : 0.04 ( 9%) usr 0.08 (80%) sys 0.12 (26%) wall read: parse : 0.05 (10%) usr 0.00 ( 0%) sys 0.05 (10%) wall work : 0.33 (70%) usr 0.00 ( 0%) sys 0.35 (71%) wall work: phase 1 : 0.30 (64%) usr 0.00 ( 0%) sys 0.30 (64%) wall work: phase 2 : 0.13 (28%) usr 0.00 ( 0%) sys 0.14 (29%) wall output : 0.04 ( 9%) usr 0.02 (20%) sys 0.04 ( 8%) wall total time : 0.47 0.10 0.49 @end smallexample To set up @code{timevar}, copy the stub file @file{gnulib/lib/timevar.def} next to where @file{timevar.h} and @file{timevar.c} were imported in your project, and define your timers there. For instance: @smallexample /* The total execution time. Mandatory. */ DEFTIMEVAR (tv_total, "total time") /* Examples. */ DEFTIMEVAR (tv_read, "read") DEFTIMEVAR (tv_work, "work") DEFTIMEVAR (tv_work_1, "work: phase 1") DEFTIMEVAR (tv_work_2, "work: phase 2") DEFTIMEVAR (tv_output, "output") @end smallexample Do not remove @code{tv_total}, it is mandatory. You may change its associated string. @sp 1 Use @code{timevar_push}/@code{timevar_pop} to start/stop timers, as in the following example. @smallexample #include <config.h> #include "timevar.h" #include <stdio.h> #include "read.h" #include "work.h" #include "output.h" int main (void) @{ timevar_enabled = true; timevar_init (); timevar_start (tv_total); timevar_push (tv_read); reader (); timevar_pop (tv_read); timevar_push (tv_work); work (); timevar_pop (tv_work); timevar_push (tv_output); output (); timevar_pop (tv_output); timevar_stop (tv_total); timevar_print (stderr); @} @end smallexample @noindent with, for instance, in @file{work.c} @smallexample #include <config.h> #include "work.h" void work (void) @{ timevar_push (tv_work_phase1); work1 (); timevar_pop (tv_work_phase1); timevar_push (tv_work_phase2); work2 (); timevar_pop (tv_work_phase2); @} @end smallexample