Profiler

Profiler is provided to identify problems in constraint propagation.

Source code setting

To profile source code written in non-C language, the following functions should be used to provide mapping to source code lines.

void cs_setProfilerLocator(const char *fmt, const char *(*locator)(void*), void *extra)

locator is a function to get location in source code.

extra is a pointer to void given when locator is called.

locator must return a string in format as fmt. (Note: If you trace native stack, back 2 levels. because this function will be called in following seqence: user code > constraint setting > locator)

fmt indicates string format which will be retured from locator.

  • “linux_addr2line”: a text from backtrace_symbols in gcc

  • “darwin_atos”: a text from backtrace_symbols in clang

  • “generic”: a tab-connected string of the following fields: filename,line,adderss,function_name

Constructor and Destructor

Profiler Object (type CSprofier) will be created and destroyed by the following function.

CSprofiler *cs_createProfiler(int profilerType)

Create profiler object that profiles events indicated by profilerType. 0 (Constraint profiler) is a valid value.

void cs_deleteProfiler(CSprofiler *profiler)

Destroy objects referenced by profiler.

Profiler functions

The following functions are used to manipulate profilers.

void cs_enableProfiler(CSprofiler *profiler)

Start profiling by the profiler.

void cs_disableProfiler(CSprofiler *profiler)

Stop profiling by the profiler.

void cs_profilerWrite(CSprofiler *profiler, FILE *fp)

Write the result of profiler to the stream referenced by fp.

void cs_profilerWriteFile(CSprofiler *profiler, const char *filename);

Write the result of profiler to the file named filename

Profiling Result

Format Result

Perl is used to format result. (Perl interpreter must be installed in your system)

If the directory where IZ-Profiler is extracted is <IZP_DIR> and the file name output by cs_profilerWriteFile is izprof.txt, you can obtain the formatted result by executing the following command:

perl <IZP_DIR>/script/izprof2html.pl izprof.txt

Output directory can be changeed by using “-o” option.

Constraint Profiler (profilerType = 0)

The constraint profiler counts the number of constraint propagation occurrences and the number of failures for each constraint. However, for constraints set on the same line, such as within a loop, multiple constraints are combined into one and counted.

Result items

  • falls : Total number of constraint failures in the line of source code.

  • calls : Total number of constraint propagations in the line of source code.

  • max_fails : Maximum number of constraint failures in the line of source code.

  • max_calls : Maximum number of constraint propagations in the line of source code.

  • n : Number of constraints set in the same line of source code that caused constraint propagation

  • location : location in the source code.

  • constraint : constraint name of iZ-C