| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <glib.h> |
| 24 |
|
| 25 |
#ifndef PACKAGE_VERSION |
| 26 |
# error "config.h was not included before dex-profiler.h." |
| 27 |
#endif |
| 28 |
|
| 29 |
#ifdef HAVE_SYSPROF |
| 30 |
# include <sysprof-capture.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
G_BEGIN_DECLS |
| 34 |
|
| 35 |
#ifdef HAVE_SYSPROF |
| 36 |
# define DEX_PROFILER_ENABLED 1 |
| 37 |
# define DEX_PROFILER_CURRENT_TIME SYSPROF_CAPTURE_CURRENT_TIME |
| 38 |
# define DEX_PROFILER_ACTIVE (sysprof_collector_is_active()) |
| 39 |
# define DEX_PROFILER_BEGIN_MARK \ |
| 40 |
G_STMT_START { \ |
| 41 |
gint64 __begin_time = SYSPROF_CAPTURE_CURRENT_TIME; |
| 42 |
# define DEX_PROFILER_END_MARK(name, message) \ |
| 43 |
G_STMT_START { \ |
| 44 |
gint64 __duration = SYSPROF_CAPTURE_CURRENT_TIME - __begin_time; \ |
| 45 |
sysprof_collector_mark (__begin_time, __duration, "libdex", name, message); \ |
| 46 |
} G_STMT_END; \ |
| 47 |
} G_STMT_END |
| 48 |
# define DEX_PROFILER_MARK(duration, name, message) \ |
| 49 |
G_STMT_START { \ |
| 50 |
sysprof_collector_mark (SYSPROF_CAPTURE_CURRENT_TIME - (duration), \ |
| 51 |
(duration), "libdex", name, message); \ |
| 52 |
} G_STMT_END |
| 53 |
# define DEX_PROFILER_MARK_AT_TIME(begin_time, duration, name, message) \ |
| 54 |
G_STMT_START { \ |
| 55 |
sysprof_collector_mark ((begin_time), (duration), "libdex", name, message); \ |
| 56 |
} G_STMT_END |
| 57 |
# define DEX_PROFILER_LOG(format, ...) \ |
| 58 |
G_STMT_START { \ |
| 59 |
if (DEX_PROFILER_ACTIVE) \ |
| 60 |
sysprof_collector_log_printf(G_LOG_LEVEL_DEBUG, G_LOG_DOMAIN, format, __VA_ARGS__); \ |
| 61 |
} G_STMT_END |
| 62 |
#else |
| 63 |
# undef DEX_PROFILER_ENABLED |
| 64 |
# define DEX_PROFILER_ACTIVE (0) |
| 65 |
# define DEX_PROFILER_CURRENT_TIME 0 |
| 66 |
# define DEX_PROFILER_MARK(duration, name, message) \ |
| 67 |
G_STMT_START { } G_STMT_END |
| 68 |
# define DEX_PROFILER_MARK_AT_TIME(begin_time, duration, name, message) \ |
| 69 |
G_STMT_START { } G_STMT_END |
| 70 |
# define DEX_PROFILER_BEGIN_MARK G_STMT_START { |
| 71 |
# define DEX_PROFILER_END_MARK(name, message) (void)0; } G_STMT_END |
| 72 |
# define DEX_PROFILER_LOG(format, ...) G_STMT_START { } G_STMT_END |
| 73 |
#endif |
| 74 |
|
| 75 |
G_END_DECLS |