Skip to content

Commit

Permalink
#81 [Core] Added an option to choose function names format
Browse files Browse the repository at this point in the history
  • Loading branch information
cas4ey committed Nov 28, 2017
1 parent df93c14 commit ef7d9f0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions easy_profiler_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 -------")
Expand Down Expand Up @@ -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.
#####################################################################
Expand Down
4 changes: 2 additions & 2 deletions easy_profiler_core/include/easy/arbitrary_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion easy_profiler_core/include/easy/details/easy_compiler_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion easy_profiler_core/include/easy/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ef7d9f0

Please sign in to comment.