#include "libut/ut.h" int UT_prf_create(char *name, char *description, UT_prf_scale scale);
This function defines a profiling group. Profiling statistics that are later added to this profiling group will be printed together in the output of the prf control port command under a common banner having the name, description and scale given in the arguments.
The name and description will be copied and silently truncated to their maximum allowed length if necessary. The description is used only in the output of the control port prf command.
scale is one of the following pre-defined scales:
Selecting a scale is somewhat a matter of intuition for the time range over which a given statistic may vary.
Once a profiling group has been defined, commonly-used sections of code can be
surrounded with a UT_prf_bgn(3)
and UT_prf_end(3)
pair of statements. This
tracks the execution time of that section of code on an ongoing basis. The
prf control port command displays these timings in the form of a histograms.
The prf control port command displays the profiling statistics among other capabilities. See the control port online help.
/* At program startup define the prf */ UT_prf_create("database", "probase query timings", te_log_1m_10s); /* Later in some occasional function call... */ UT_prf_bgn("database", "db-read"); ... database read code... UT_prf_end("database", "db-read"); UT_prf_bgn("database", "db-write"); ... database write code... UT_prf_end("database", "db-write");
After running the read and write routines some number of times, the prf control port command output may look like this:
================================================================= database -- probase query timings ================================================================= name count <1m 1-10m 10-100m 0.1-1s 1-10s >10s --------------------- ------- --- ----- ------- ------ ----- ---- db-read 10 60% 40% db-write 2 30% 70%
Troy D. Hanson <thanson@users.sourceforge.net>