Source
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
typedef struct
{
const char *func_name;
double start;
double sec;
double sec_wait;
unsigned int locked;
zbx_prof_scope_t scope;
}
zbx_func_profile_t;
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);
return 0;
}