navit  0.5.3-trunk
profile.h File Reference

Go to the source code of this file.

Macros

#define profile_str2(x)   #x
 
#define profile_str1(x)   profile_str2(x)
 
#define profile_module   profile_str1(MODULE)
 
#define profile(level, ...)   profile_timer(level,profile_module,__PRETTY_FUNCTION__,__VA_ARGS__)
 

Functions

void profile_timer (int level, const char *module, const char *function, const char *fmt,...)
 Log timing information. More...
 

Macro Definition Documentation

◆ profile

#define profile (   level,
  ... 
)    profile_timer(level,profile_module,__PRETTY_FUNCTION__,__VA_ARGS__)

◆ profile_module

#define profile_module   profile_str1(MODULE)

◆ profile_str1

#define profile_str1 (   x)    profile_str2(x)

◆ profile_str2

#define profile_str2 (   x)    #x

Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Function Documentation

◆ profile_timer()

void profile_timer ( int  level,
const char *  module,
const char *  function,
const char *  fmt,
  ... 
)

Log timing information.

Note
Normally this function is called via the macro 'profile', which automatically fills in parameters 'module' and 'function'.

Successive calls to this function will print the elapsed time between calls, using an internal timer. To start/reset the internal timer without printing a message, set parameter 'fmt' to NULL.

To run multiple timers in parallel, the parameter 'level' can be used. Each invocation will print the elapsed time to the last invocation with the same level. As an exception, calling with 'fmt'=NULL wll reset all timers with a level greater or equal to the level parameter.

Typically, profiling is started by calling profile(0, NULL). Then calls with various levels can be used to print different intermediate timings.

Parameters
levellevel of timer to use (0 to PROFILE_LEVEL_MAX).
modulename of current module (for logging)
functionname of current function (for logging)
fmtformat string Log message to print (as a printf format string), followed by required parameters as varargs. May be NULL; then no message is printed, and all timers with the same or higher level are reset.

References debug_printf(), debug_vprintf(), lvl_debug, and PROFILE_LEVEL_MAX.