mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
#81 [Core] Added an option to choose function names format
This commit is contained in:
parent
df93c146b2
commit
ef7d9f0bad
@ -40,6 +40,7 @@ set(EASY_OPTION_LISTEN OFF CACHE BOOL "Enable automatic sta
|
||||
set(EASY_OPTION_PROFILE_SELF OFF CACHE BOOL "Enable self profiling (measure time for internal storage expand)")
|
||||
set(EASY_OPTION_PROFILE_SELF_BLOCKS_ON OFF CACHE BOOL "Storage expand default status (profiler::ON or profiler::OFF)")
|
||||
set(EASY_OPTION_LOG OFF CACHE BOOL "Print errors to stderr")
|
||||
set(EASY_OPTION_PRETTY_PRINT OFF CACHE BOOL "Use pretty-printed function names with signature and argument types")
|
||||
set(EASY_OPTION_PREDEFINED_COLORS ON CACHE BOOL "Use predefined set of colors (see profiler_colors.h). If you want to use your own colors palette you can turn this option OFF")
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build easy_profiler as shared library.")
|
||||
if (WIN32)
|
||||
@ -98,6 +99,7 @@ elseif (NO_CXX11_THREAD_LOCAL_SUPPORT)
|
||||
endif ()
|
||||
endif ()
|
||||
message(STATUS " Log messages = ${EASY_OPTION_LOG}")
|
||||
message(STATUS " Function names pretty-print = ${EASY_OPTION_PRETTY_PRINT}")
|
||||
message(STATUS " Use EasyProfiler colors palette = ${EASY_OPTION_PREDEFINED_COLORS}")
|
||||
message(STATUS " Shared library: ${BUILD_SHARED_LIBS}")
|
||||
message(STATUS "------ END EASY_PROFILER OPTIONS -------")
|
||||
@ -196,6 +198,7 @@ else ()
|
||||
easy_define_target_option(easy_profiler EASY_OPTION_REMOVE_EMPTY_UNGUARDED_THREADS EASY_OPTION_REMOVE_EMPTY_UNGUARDED_THREADS)
|
||||
endif ()
|
||||
easy_define_target_option(easy_profiler EASY_OPTION_LOG EASY_OPTION_LOG_ENABLED)
|
||||
easy_define_target_option(easy_profiler EASY_OPTION_PRETTY_PRINT EASY_OPTION_PRETTY_PRINT_FUNCTIONS)
|
||||
easy_define_target_option(easy_profiler EASY_OPTION_PREDEFINED_COLORS EASY_OPTION_BUILTIN_COLORS)
|
||||
# End adding EasyProfiler options definitions.
|
||||
#####################################################################
|
||||
|
@ -73,8 +73,8 @@ void bar(const A& b) {
|
||||
}
|
||||
|
||||
void baz(const A& c) {
|
||||
EASY_VALUE("baz count", c.someCount, EASY_VIN(__func__)); // Different ID from "foo count" and "bar count"
|
||||
EASY_VALUE("qux count", 100500, EASY_VIN(__func__)); // Same ID as for "baz count"
|
||||
EASY_VALUE("baz count", c.someCount, EASY_VIN(EASY_FUNC_NAME)); // Different ID from "foo count" and "bar count"
|
||||
EASY_VALUE("qux count", 100500, EASY_VIN(EASY_FUNC_NAME)); // Same ID as for "baz count"
|
||||
}
|
||||
\endcode
|
||||
|
||||
|
@ -68,7 +68,11 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Visual Studio
|
||||
|
||||
# define __func__ __FUNCTION__
|
||||
# if defined(EASY_OPTION_PRETTY_PRINT_FUNCTIONS) && EASY_OPTION_PRETTY_PRINT_FUNCTIONS != 0
|
||||
# define EASY_FUNC_NAME __FUNCSIG__
|
||||
# else
|
||||
# define EASY_FUNC_NAME __FUNCTION__
|
||||
# endif
|
||||
|
||||
# if _MSC_VER <= 1800
|
||||
// There is no support for C++11 thread_local keyword prior to Visual Studio 2015. Use __declspec(thread) instead.
|
||||
@ -173,6 +177,14 @@ static_assert(false, "EasyProfiler is not configured for using your compiler typ
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Default values
|
||||
|
||||
#ifndef EASY_FUNC_NAME
|
||||
# if defined(EASY_OPTION_PRETTY_PRINT_FUNCTIONS) && EASY_OPTION_PRETTY_PRINT_FUNCTIONS != 0
|
||||
# define EASY_FUNC_NAME __PRETTY_FUNCTION__
|
||||
# else
|
||||
# define EASY_FUNC_NAME __func__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef EASY_THREAD_LOCAL
|
||||
# define EASY_THREAD_LOCAL thread_local
|
||||
# define EASY_CXX11_TLS_AVAILABLE
|
||||
|
@ -176,7 +176,7 @@ Name of the block automatically created with function name.
|
||||
|
||||
\ingroup profiler
|
||||
*/
|
||||
# define EASY_FUNCTION(...) EASY_BLOCK(__func__, ## __VA_ARGS__)
|
||||
# define EASY_FUNCTION(...) EASY_BLOCK(EASY_FUNC_NAME, ## __VA_ARGS__)
|
||||
|
||||
/** Macro for completion of last opened block explicitly.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user