#define PROF_LEVEL_MAX 10
ZBX_PTR_VECTOR_DECL(func_profiles, zbx_func_profile_t*)
ZBX_PTR_VECTOR_IMPL(func_profiles, zbx_func_profile_t*)
static volatile int zbx_prof_scope_requested;
static ZBX_THREAD_LOCAL zbx_vector_func_profiles_t zbx_func_profiles;
static ZBX_THREAD_LOCAL zbx_prof_scope_t zbx_prof_scope;
static ZBX_THREAD_LOCAL int zbx_prof_initialized;
static ZBX_THREAD_LOCAL zbx_func_profile_t *zbx_func_profile[PROF_LEVEL_MAX];
static ZBX_THREAD_LOCAL int zbx_func_profile_level;
static void zbx_prof_init(void)
if (0 == zbx_prof_initialized)
zbx_prof_initialized = 1;
zbx_vector_func_profiles_create(&zbx_func_profiles);
static int compare_func_profile(const void *d1, const void *d2)
const zbx_func_profile_t *func_profile1 = *((const zbx_func_profile_t * const *)d1);
const zbx_func_profile_t *func_profile2 = *((const zbx_func_profile_t * const *)d2);
ZBX_RETURN_IF_NOT_EQUAL(func_profile1->func_name, func_profile2->func_name);
static void func_profile_free(zbx_func_profile_t *func_profile)
void zbx_prof_start(const char *func_name, zbx_prof_scope_t scope)
zbx_func_profile_t *func_profile, func_profile_local = {.func_name = func_name};
if (FAIL == (i = zbx_vector_func_profiles_bsearch(&zbx_func_profiles, &func_profile_local,
func_profile = zbx_malloc(NULL, sizeof(zbx_func_profile_t));
func_profile->func_name = func_name;
func_profile->locked = 0;
func_profile->sec_wait = 0;
func_profile->scope = scope;
zbx_vector_func_profiles_append(&zbx_func_profiles, func_profile);
zbx_vector_func_profiles_sort(&zbx_func_profiles, compare_func_profile);
func_profile = zbx_func_profiles.values[i];
func_profile->start = zbx_time();
zbx_func_profile[zbx_func_profile_level] = func_profile;
zbx_func_profile_level++;
void zbx_prof_end_wait(void)
zbx_func_profile_t *func_profile;