eina: add eina_log_timing.
This commit is contained in:
parent
e12dbaeae6
commit
1d5692baa6
|
@ -1,9 +1,12 @@
|
||||||
|
2013-03-27 Cedric Bail
|
||||||
|
|
||||||
|
* Eina: Add eina_log_timing.
|
||||||
|
|
||||||
2013-03-27 Jihoon Kim
|
2013-03-27 Jihoon Kim
|
||||||
|
|
||||||
* Add ecore_imf_context_input_panel_variation_set/get API.
|
* Add ecore_imf_context_input_panel_variation_set/get API.
|
||||||
* Add edje_object_part_text_input_panel_layout_variation_set/get API.
|
* Add edje_object_part_text_input_panel_layout_variation_set/get API.
|
||||||
|
|
||||||
|
|
||||||
2013-03-25 Cedric Bail
|
2013-03-25 Cedric Bail
|
||||||
|
|
||||||
* Eina: add portable eina_file_mkstemp().
|
* Eina: add portable eina_file_mkstemp().
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -22,6 +22,7 @@ Additions:
|
||||||
- Add eina_log_print_cb_journald()
|
- Add eina_log_print_cb_journald()
|
||||||
- Add eina_list_shuffle()
|
- Add eina_list_shuffle()
|
||||||
- Add eina_file_mkstemp()
|
- Add eina_file_mkstemp()
|
||||||
|
- Add eina_log_timing()
|
||||||
* Add Cserve2 scalecache support
|
* Add Cserve2 scalecache support
|
||||||
* ecore_x:
|
* ecore_x:
|
||||||
- Add window profile support.
|
- Add window profile support.
|
||||||
|
|
|
@ -24,14 +24,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#ifndef _WIN32
|
|
||||||
# include <time.h>
|
|
||||||
# include <sys/time.h>
|
|
||||||
#else
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# include <windows.h>
|
|
||||||
# undef WIN32_LEAN_AND_MEAN
|
|
||||||
#endif /* _WIN2 */
|
|
||||||
|
|
||||||
#include "eina_config.h"
|
#include "eina_config.h"
|
||||||
#include "eina_private.h"
|
#include "eina_private.h"
|
||||||
|
@ -46,6 +38,8 @@
|
||||||
# include <Escape.h>
|
# include <Escape.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "eina_private.h"
|
||||||
|
|
||||||
/*============================================================================*
|
/*============================================================================*
|
||||||
* Local *
|
* Local *
|
||||||
*============================================================================*/
|
*============================================================================*/
|
||||||
|
@ -54,12 +48,6 @@
|
||||||
* @cond LOCAL
|
* @cond LOCAL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
typedef struct timespec Eina_Nano_Time;
|
|
||||||
#else
|
|
||||||
typedef LARGE_INTEGER Eina_Nano_Time;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct _Eina_Clock Eina_Clock;
|
typedef struct _Eina_Clock Eina_Clock;
|
||||||
|
|
||||||
struct _Eina_Counter
|
struct _Eina_Counter
|
||||||
|
@ -81,40 +69,12 @@ struct _Eina_Clock
|
||||||
Eina_Bool valid;
|
Eina_Bool valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifdef _WIN32
|
||||||
static inline int
|
|
||||||
_eina_counter_time_get(Eina_Nano_Time *tp)
|
|
||||||
{
|
|
||||||
# if defined(CLOCK_PROCESS_CPUTIME_ID)
|
|
||||||
return clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp);
|
|
||||||
# elif defined(CLOCK_PROF)
|
|
||||||
return clock_gettime(CLOCK_PROF, tp);
|
|
||||||
# elif defined(CLOCK_REALTIME)
|
|
||||||
return clock_gettime(CLOCK_REALTIME, tp);
|
|
||||||
# else
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
tp->tv_sec = tv.tv_sec;
|
|
||||||
tp->tv_nsec = tv.tv_usec * 1000L;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static const char EINA_ERROR_COUNTER_WINDOWS_STR[] =
|
static const char EINA_ERROR_COUNTER_WINDOWS_STR[] =
|
||||||
"Change your OS, you moron !";
|
"Change your OS, you moron !";
|
||||||
static int EINA_ERROR_COUNTER_WINDOWS = 0;
|
static int EINA_ERROR_COUNTER_WINDOWS = 0;
|
||||||
static LARGE_INTEGER _eina_counter_frequency;
|
LARGE_INTEGER _eina_counter_frequency;
|
||||||
|
#endif
|
||||||
static inline int
|
|
||||||
_eina_counter_time_get(Eina_Nano_Time *tp)
|
|
||||||
{
|
|
||||||
return QueryPerformanceCounter(tp);
|
|
||||||
}
|
|
||||||
#endif /* _WIN2 */
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_eina_counter_asiprintf(char *base, int *position, const char *format, ...)
|
_eina_counter_asiprintf(char *base, int *position, const char *format, ...)
|
||||||
|
@ -265,10 +225,10 @@ eina_counter_start(Eina_Counter *counter)
|
||||||
Eina_Nano_Time tp;
|
Eina_Nano_Time tp;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(counter);
|
EINA_SAFETY_ON_NULL_RETURN(counter);
|
||||||
if (_eina_counter_time_get(&tp) != 0)
|
if (_eina_time_get(&tp) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eina_error_set(0);
|
eina_error_set(0);
|
||||||
clk = calloc(1, sizeof (Eina_Clock));
|
clk = calloc(1, sizeof (Eina_Clock));
|
||||||
if (!clk)
|
if (!clk)
|
||||||
{
|
{
|
||||||
|
@ -289,7 +249,7 @@ eina_counter_stop(Eina_Counter *counter, int specimen)
|
||||||
Eina_Nano_Time tp;
|
Eina_Nano_Time tp;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(counter);
|
EINA_SAFETY_ON_NULL_RETURN(counter);
|
||||||
if (_eina_counter_time_get(&tp) != 0)
|
if (_eina_time_get(&tp) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = (Eina_Clock *)counter->clocks;
|
clk = (Eina_Clock *)counter->clocks;
|
||||||
|
@ -327,28 +287,9 @@ eina_counter_dump(Eina_Counter *counter)
|
||||||
if (clk->valid == EINA_FALSE)
|
if (clk->valid == EINA_FALSE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifndef _WIN32
|
start = _eina_time_convert(&clk->start);
|
||||||
start = clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
|
end = _eina_time_convert(&clk->end);
|
||||||
end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
|
diff = _eina_time_delta(&clk->start, &clk->end);
|
||||||
diff =
|
|
||||||
(clk->end.tv_sec -
|
|
||||||
clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec -
|
|
||||||
clk->start.tv_nsec;
|
|
||||||
#else
|
|
||||||
start =
|
|
||||||
(long int)(((long long int)clk->start.QuadPart *
|
|
||||||
1000000000ll) /
|
|
||||||
(long long int)_eina_counter_frequency.QuadPart);
|
|
||||||
end =
|
|
||||||
(long int)(((long long int)clk->end.QuadPart *
|
|
||||||
1000000000LL) /
|
|
||||||
(long long int)_eina_counter_frequency.QuadPart);
|
|
||||||
diff =
|
|
||||||
(long int)(((long long int)(clk->end.QuadPart -
|
|
||||||
clk->start.QuadPart) *
|
|
||||||
1000000000LL) /
|
|
||||||
(long long int)_eina_counter_frequency.QuadPart);
|
|
||||||
#endif /* _WIN2 */
|
|
||||||
|
|
||||||
result = _eina_counter_asiprintf(result, &position,
|
result = _eina_counter_asiprintf(result, &position,
|
||||||
"%i\t%li\t%li\t%li\n",
|
"%i\t%li\t%li\t%li\n",
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/* EINA - EFL data type library
|
||||||
|
* Copyright (C) 2013 Cedric Bail
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library;
|
||||||
|
* if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EINA_INLINE_PRIVATE_H_
|
||||||
|
# define EINA_INLINE_PRIVATE_H_
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
# include <time.h>
|
||||||
|
# include <sys/time.h>
|
||||||
|
#else
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
# undef WIN32_LEAN_AND_MEAN
|
||||||
|
#endif /* _WIN2 */
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
typedef struct timespec Eina_Nano_Time;
|
||||||
|
#else
|
||||||
|
typedef LARGE_INTEGER Eina_Nano_Time;
|
||||||
|
|
||||||
|
extern LARGE_INTEGER _eina_counter_frequency;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
_eina_time_get(Eina_Nano_Time *tp)
|
||||||
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
# if defined(CLOCK_PROCESS_CPUTIME_ID)
|
||||||
|
return clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp);
|
||||||
|
# elif defined(CLOCK_PROF)
|
||||||
|
return clock_gettime(CLOCK_PROF, tp);
|
||||||
|
# elif defined(CLOCK_REALTIME)
|
||||||
|
return clock_gettime(CLOCK_REALTIME, tp);
|
||||||
|
# else
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
if (gettimeofday(&tv, NULL))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
tp->tv_sec = tv.tv_sec;
|
||||||
|
tp->tv_nsec = tv.tv_usec * 1000L;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
return QueryPerformanceCounter(tp);
|
||||||
|
#endif /* _WIN2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline long int
|
||||||
|
_eina_time_convert(Eina_Nano_Time *tp)
|
||||||
|
{
|
||||||
|
long int r;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
r = tp->tv_sec * 1000000000 + tp->tv_nsec;
|
||||||
|
#else
|
||||||
|
r = (long int)(((long long int)tp->QuadPart * 1000000000ll) /
|
||||||
|
(long long int)_eina_counter_frequency.QuadPart);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline long int
|
||||||
|
_eina_time_delta(Eina_Nano_Time *start, Eina_Nano_Time *end)
|
||||||
|
{
|
||||||
|
long int r;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
r = (end->tv_sec - start->tv_sec) * 1000000000 +
|
||||||
|
end->tv_nsec - start->tv_nsec;
|
||||||
|
#else
|
||||||
|
r = (long int)(((long long int)(end->QuadPart - start->QuadPart)
|
||||||
|
* 1000000000LL)
|
||||||
|
/ (long long int)_eina_counter_frequency.QuadPart);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -54,6 +54,8 @@
|
||||||
#include "eina_safety_checks.h"
|
#include "eina_safety_checks.h"
|
||||||
#include "eina_log.h"
|
#include "eina_log.h"
|
||||||
|
|
||||||
|
#include "eina_inline_private.h"
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
* + printing logs to stdout or stderr can be implemented
|
* + printing logs to stdout or stderr can be implemented
|
||||||
* using a queue, useful for multiple threads printing
|
* using a queue, useful for multiple threads printing
|
||||||
|
@ -91,6 +93,14 @@ struct _Eina_Log_Domain_Level_Pending
|
||||||
char name[];
|
char name[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _Eina_Log_Timing Eina_Log_Timing;
|
||||||
|
struct _Eina_Log_Timing
|
||||||
|
{
|
||||||
|
const char *phase;
|
||||||
|
Eina_Nano_Time start;
|
||||||
|
Eina_Log_State state;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of levels for domains set by the user before the domains are registered,
|
* List of levels for domains set by the user before the domains are registered,
|
||||||
* updates the domain levels on the first log and clears itself.
|
* updates the domain levels on the first log and clears itself.
|
||||||
|
@ -104,6 +114,7 @@ static Eina_Bool _disable_color = EINA_FALSE;
|
||||||
static Eina_Bool _disable_file = EINA_FALSE;
|
static Eina_Bool _disable_file = EINA_FALSE;
|
||||||
static Eina_Bool _disable_function = EINA_FALSE;
|
static Eina_Bool _disable_function = EINA_FALSE;
|
||||||
static Eina_Bool _abort_on_critical = EINA_FALSE;
|
static Eina_Bool _abort_on_critical = EINA_FALSE;
|
||||||
|
static Eina_Bool _disable_timing = EINA_TRUE;
|
||||||
static int _abort_level_on_critical = EINA_LOG_LEVEL_CRITICAL;
|
static int _abort_level_on_critical = EINA_LOG_LEVEL_CRITICAL;
|
||||||
|
|
||||||
#ifdef EINA_LOG_BACKTRACE
|
#ifdef EINA_LOG_BACKTRACE
|
||||||
|
@ -179,6 +190,7 @@ static Eina_Lock _log_mutex;
|
||||||
|
|
||||||
// List of domains registered
|
// List of domains registered
|
||||||
static Eina_Log_Domain *_log_domains = NULL;
|
static Eina_Log_Domain *_log_domains = NULL;
|
||||||
|
static Eina_Log_Timing *_log_timing = NULL;
|
||||||
static unsigned int _log_domains_count = 0;
|
static unsigned int _log_domains_count = 0;
|
||||||
static size_t _log_domains_allocated = 0;
|
static size_t _log_domains_allocated = 0;
|
||||||
|
|
||||||
|
@ -940,7 +952,8 @@ eina_log_domain_str_get(const char *name, const char *color)
|
||||||
* constructor acts upon an pre-allocated object.
|
* constructor acts upon an pre-allocated object.
|
||||||
*/
|
*/
|
||||||
static Eina_Log_Domain *
|
static Eina_Log_Domain *
|
||||||
eina_log_domain_new(Eina_Log_Domain *d, const char *name, const char *color)
|
eina_log_domain_new(Eina_Log_Domain *d, Eina_Log_Timing *t,
|
||||||
|
const char *name, const char *color)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
||||||
|
@ -956,6 +969,8 @@ eina_log_domain_new(Eina_Log_Domain *d, const char *name, const char *color)
|
||||||
d->name = strdup(name);
|
d->name = strdup(name);
|
||||||
d->namelen = strlen(name);
|
d->namelen = strlen(name);
|
||||||
|
|
||||||
|
t->phase = NULL;
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,7 +1097,7 @@ eina_log_domain_register_unlocked(const char *name, const char *color)
|
||||||
if (_log_domains[i].deleted)
|
if (_log_domains[i].deleted)
|
||||||
{
|
{
|
||||||
// Found a flagged slot, free domain_str and replace slot
|
// Found a flagged slot, free domain_str and replace slot
|
||||||
eina_log_domain_new(&_log_domains[i], name, color);
|
eina_log_domain_new(&_log_domains[i], &_log_timing[i], name, color);
|
||||||
goto finish_register;
|
goto finish_register;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1090,6 +1105,7 @@ eina_log_domain_register_unlocked(const char *name, const char *color)
|
||||||
if (_log_domains_count >= _log_domains_allocated)
|
if (_log_domains_count >= _log_domains_allocated)
|
||||||
{
|
{
|
||||||
Eina_Log_Domain *tmp;
|
Eina_Log_Domain *tmp;
|
||||||
|
Eina_Log_Timing *tim;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
if (!_log_domains)
|
if (!_log_domains)
|
||||||
|
@ -1100,19 +1116,25 @@ eina_log_domain_register_unlocked(const char *name, const char *color)
|
||||||
size = _log_domains_allocated + 8;
|
size = _log_domains_allocated + 8;
|
||||||
|
|
||||||
tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
|
tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
|
||||||
|
tim = realloc(_log_timing, sizeof (Eina_Log_Timing) * size);
|
||||||
|
|
||||||
if (tmp)
|
if (tmp && tim)
|
||||||
{
|
{
|
||||||
// Success!
|
// Success!
|
||||||
_log_domains = tmp;
|
_log_domains = tmp;
|
||||||
|
_log_timing = tim;
|
||||||
_log_domains_allocated = size;
|
_log_domains_allocated = size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
{
|
||||||
|
free(tmp);
|
||||||
|
free(tim);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use an allocated slot
|
// Use an allocated slot
|
||||||
eina_log_domain_new(&_log_domains[i], name, color);
|
eina_log_domain_new(&_log_domains[i], &_log_timing[i], name, color);
|
||||||
_log_domains_count++;
|
_log_domains_count++;
|
||||||
|
|
||||||
finish_register:
|
finish_register:
|
||||||
|
@ -1143,6 +1165,8 @@ finish_register:
|
||||||
if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
|
if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
|
||||||
_log_domains[i].level = _log_level;
|
_log_domains[i].level = _log_level;
|
||||||
|
|
||||||
|
eina_log_timing(i, EINA_LOG_STATE_START, EINA_LOG_STATE_INIT);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,6 +1222,8 @@ eina_log_domain_unregister_unlocked(int domain)
|
||||||
if ((unsigned int)domain >= _log_domains_count)
|
if ((unsigned int)domain >= _log_domains_count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
eina_log_timing(domain, EINA_LOG_STATE_STOP, EINA_LOG_STATE_SHUTDOWN);
|
||||||
|
|
||||||
d = &_log_domains[domain];
|
d = &_log_domains[domain];
|
||||||
eina_log_domain_free(d);
|
eina_log_domain_free(d);
|
||||||
d->deleted = 1;
|
d->deleted = 1;
|
||||||
|
@ -1365,6 +1391,9 @@ eina_log_init(void)
|
||||||
_print_cb = eina_log_print_cb_journald;
|
_print_cb = eina_log_print_cb_journald;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (getenv("EINA_LOG_TIMING"))
|
||||||
|
_disable_timing = EINA_FALSE;
|
||||||
|
|
||||||
if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1))
|
if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1))
|
||||||
_disable_file = EINA_TRUE;
|
_disable_file = EINA_TRUE;
|
||||||
|
|
||||||
|
@ -1402,6 +1431,10 @@ eina_log_init(void)
|
||||||
// Parse pending domains passed through EINA_LOG_LEVELS
|
// Parse pending domains passed through EINA_LOG_LEVELS
|
||||||
eina_log_domain_parse_pendings();
|
eina_log_domain_parse_pendings();
|
||||||
|
|
||||||
|
eina_log_timing(EINA_LOG_DOMAIN_GLOBAL,
|
||||||
|
EINA_LOG_STATE_STOP,
|
||||||
|
EINA_LOG_STATE_INIT);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1427,6 +1460,10 @@ eina_log_shutdown(void)
|
||||||
#ifdef EINA_ENABLE_LOG
|
#ifdef EINA_ENABLE_LOG
|
||||||
Eina_Inlist *tmp;
|
Eina_Inlist *tmp;
|
||||||
|
|
||||||
|
eina_log_timing(EINA_LOG_DOMAIN_GLOBAL,
|
||||||
|
EINA_LOG_STATE_START,
|
||||||
|
EINA_LOG_STATE_SHUTDOWN);
|
||||||
|
|
||||||
while (_log_domains_count--)
|
while (_log_domains_count--)
|
||||||
{
|
{
|
||||||
if (_log_domains[_log_domains_count].deleted)
|
if (_log_domains[_log_domains_count].deleted)
|
||||||
|
@ -1435,7 +1472,8 @@ eina_log_shutdown(void)
|
||||||
eina_log_domain_free(&_log_domains[_log_domains_count]);
|
eina_log_domain_free(&_log_domains[_log_domains_count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(_log_domains);
|
free(_log_domains);
|
||||||
|
free(_log_timing);
|
||||||
|
|
||||||
_log_domains = NULL;
|
_log_domains = NULL;
|
||||||
_log_domains_count = 0;
|
_log_domains_count = 0;
|
||||||
|
@ -2118,3 +2156,60 @@ eina_log_console_color_set(FILE *fp, const char *color)
|
||||||
(void)color;
|
(void)color;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
eina_log_timing(int domain,
|
||||||
|
Eina_Log_State state,
|
||||||
|
const char *phase)
|
||||||
|
{
|
||||||
|
Eina_Log_Domain *d;
|
||||||
|
Eina_Log_Timing *t;
|
||||||
|
|
||||||
|
if (_disable_timing) return ;
|
||||||
|
|
||||||
|
d = _log_domains + domain;
|
||||||
|
t = _log_timing + domain;
|
||||||
|
#ifdef EINA_SAFETY_CHECKS
|
||||||
|
if (EINA_UNLIKELY(d->deleted))
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"ERR: eina_log_print() domain %d is deleted\n",
|
||||||
|
domain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (t->phase == EINA_LOG_STATE_INIT &&
|
||||||
|
phase == EINA_LOG_STATE_SHUTDOWN)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
if (state == EINA_LOG_STATE_START &&
|
||||||
|
t->phase &&
|
||||||
|
strcmp(t->phase, phase)) // Different phase
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s vs %s\n", t->phase, phase);
|
||||||
|
eina_log_timing(domain, EINA_LOG_STATE_STOP, t->phase);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case EINA_LOG_STATE_START:
|
||||||
|
{
|
||||||
|
_eina_time_get(&t->start);
|
||||||
|
t->phase = phase;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EINA_LOG_STATE_STOP:
|
||||||
|
{
|
||||||
|
Eina_Nano_Time end;
|
||||||
|
long int r;
|
||||||
|
|
||||||
|
_eina_time_get(&end);
|
||||||
|
r = _eina_time_delta(&t->start, &end);
|
||||||
|
EINA_LOG_DOM_INFO(domain, "%s timing: %li", t->phase, r);
|
||||||
|
|
||||||
|
t->phase = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -464,6 +464,12 @@ typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
|
||||||
const char *file, const char *fnc, int line,
|
const char *file, const char *fnc, int line,
|
||||||
const char *fmt, void *data, va_list args);
|
const char *fmt, void *data, va_list args);
|
||||||
|
|
||||||
|
typedef enum _Eina_Log_State
|
||||||
|
{
|
||||||
|
EINA_LOG_STATE_START,
|
||||||
|
EINA_LOG_STATE_STOP
|
||||||
|
} Eina_Log_State;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Customization
|
* Customization
|
||||||
*/
|
*/
|
||||||
|
@ -935,6 +941,26 @@ EAPI void eina_log_print_cb_journald(const Eina_Log_Domain *d,
|
||||||
EAPI void eina_log_console_color_set(FILE *fp,
|
EAPI void eina_log_console_color_set(FILE *fp,
|
||||||
const char *color) EINA_ARG_NONNULL(1, 2);
|
const char *color) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
|
#define EINA_LOG_STATE_INIT "init"
|
||||||
|
#define EINA_LOG_STATE_SHUTDOWN "shutdown"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Start or stop the timing of a phase.
|
||||||
|
*
|
||||||
|
* @param d The domain.
|
||||||
|
* @param state State indicating if we are starting or stopping a phase.
|
||||||
|
* @param phase The name of the phase to be used in the log.
|
||||||
|
*
|
||||||
|
* @note One domain can be in only one phase at a time.
|
||||||
|
* @note If you change the name of the phase, it is assumed that
|
||||||
|
* the previous phase has stopped.
|
||||||
|
* @note The phase name should be available for all the life of the timing.
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
EAPI void eina_log_timing(int domain,
|
||||||
|
Eina_Log_State state,
|
||||||
|
const char *phase) EINA_ARG_NONNULL(1, 3);
|
||||||
|
|
||||||
#include "eina_inline_log.x"
|
#include "eina_inline_log.x"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -310,6 +310,8 @@ eina_init(void)
|
||||||
|
|
||||||
eina_cpu_count_internal();
|
eina_cpu_count_internal();
|
||||||
|
|
||||||
|
eina_log_timing(_eina_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
|
||||||
|
|
||||||
_eina_main_count = 1;
|
_eina_main_count = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -325,6 +327,10 @@ eina_shutdown(void)
|
||||||
_eina_main_count--;
|
_eina_main_count--;
|
||||||
if (EINA_UNLIKELY(_eina_main_count == 0))
|
if (EINA_UNLIKELY(_eina_main_count == 0))
|
||||||
{
|
{
|
||||||
|
eina_log_timing(_eina_log_dom,
|
||||||
|
EINA_LOG_STATE_START,
|
||||||
|
EINA_LOG_STATE_SHUTDOWN);
|
||||||
|
|
||||||
_eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
|
_eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
|
||||||
|
|
||||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||||
|
|
|
@ -146,5 +146,7 @@ void eina_cpu_count_internal(void);
|
||||||
|
|
||||||
void eina_file_mmap_faulty(void *addr, long page_size);
|
void eina_file_mmap_faulty(void *addr, long page_size);
|
||||||
|
|
||||||
|
#include "eina_inline_private.h"
|
||||||
|
|
||||||
#endif /* EINA_PRIVATE_H_ */
|
#endif /* EINA_PRIVATE_H_ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue