mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
CMake + core: added options to CMakeLists.txt. TODO: maybe set them via CMake "option(...)" command
This commit is contained in:
parent
b67e078e55
commit
7b63ae39d2
@ -4,6 +4,102 @@ IF (NOT DEFINED LIB_NAME)
|
|||||||
SET(LIB_NAME ${PROJECT_NAME})
|
SET(LIB_NAME ${PROJECT_NAME})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
if(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR)
|
||||||
|
file (STRINGS ${CMAKE_CURRENT_LIST_DIR}/version.info EASY_PRODUCT_VERSION_STRING)
|
||||||
|
string(REPLACE "." ";" VERSION_LIST ${EASY_PRODUCT_VERSION_STRING})
|
||||||
|
|
||||||
|
list(GET VERSION_LIST 0 EASY_PROGRAM_VERSION_MAJOR)
|
||||||
|
list(GET VERSION_LIST 1 EASY_PROGRAM_VERSION_MINOR)
|
||||||
|
list(GET VERSION_LIST 2 EASY_PROGRAM_VERSION_PATCH)
|
||||||
|
|
||||||
|
# EasyProfiler version
|
||||||
|
add_definitions(
|
||||||
|
-DEASY_PROFILER_VERSION_MAJOR=${EASY_PROGRAM_VERSION_MAJOR}
|
||||||
|
-DEASY_PROFILER_VERSION_MINOR=${EASY_PROGRAM_VERSION_MINOR}
|
||||||
|
-DEASY_PROFILER_VERSION_PATCH=${EASY_PROGRAM_VERSION_PATCH}
|
||||||
|
)
|
||||||
|
# EasyProfiler version
|
||||||
|
|
||||||
|
set(EASY_PROGRAM_VERSION_MAJOR ${EASY_PROGRAM_VERSION_MAJOR} PARENT_SCOPE)
|
||||||
|
set(EASY_PROGRAM_VERSION_MINOR ${EASY_PROGRAM_VERSION_MINOR} PARENT_SCOPE)
|
||||||
|
set(EASY_PROGRAM_VERSION_PATCH ${EASY_PROGRAM_VERSION_PATCH} PARENT_SCOPE)
|
||||||
|
|
||||||
|
endif(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR)
|
||||||
|
|
||||||
|
message(STATUS "")
|
||||||
|
message(STATUS "EASY_PROFILER.Core version = ${EASY_PROGRAM_VERSION_MAJOR}.${EASY_PROGRAM_VERSION_MINOR}.${EASY_PROGRAM_VERSION_PATCH}")
|
||||||
|
message(STATUS "")
|
||||||
|
|
||||||
|
|
||||||
|
# EasyProfiler options:----------------------------------------------
|
||||||
|
set(EASY_DEFAULT_PORT 28077) # default listening port
|
||||||
|
set(EASY_OPTION_LISTEN OFF) # enable automatic startListen on startup
|
||||||
|
set(EASY_OPTION_PROFILE_SELF OFF) # enable self profiling (measure time for internal storage expand)
|
||||||
|
set(EASY_OPTION_PROFILE_SELF_BLOCKS_ON OFF) # storage expand default status (profiler::ON or profiler::OFF)
|
||||||
|
set(EASY_OPTION_LOG OFF) # print errors to stderr
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(EASY_OPTION_EVENT_TRACING ON) # Enable event tracing by default
|
||||||
|
set(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING ON) # Set low priority for event tracing thread
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
MESSAGE(STATUS "EASY_PROFILER OPTIONS:--------------")
|
||||||
|
MESSAGE(STATUS " Default listening port\t\t= ${EASY_DEFAULT_PORT}")
|
||||||
|
MESSAGE(STATUS " Auto-start listening\t\t= ${EASY_OPTION_LISTEN}")
|
||||||
|
MESSAGE(STATUS " Profile self\t\t\t= ${EASY_OPTION_PROFILE_SELF}")
|
||||||
|
MESSAGE(STATUS " Profile self blocks initial status\t= ${EASY_OPTION_PROFILE_SELF_BLOCKS_ON}")
|
||||||
|
if(WIN32)
|
||||||
|
MESSAGE(STATUS " Event tracing\t\t\t= ${EASY_OPTION_EVENT_TRACING}")
|
||||||
|
if(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
|
||||||
|
MESSAGE(STATUS " Event tracing has low priority\t= Yes")
|
||||||
|
else()
|
||||||
|
MESSAGE(STATUS " Event tracing has low priority\t= No")
|
||||||
|
endif(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
|
||||||
|
endif(WIN32)
|
||||||
|
MESSAGE(STATUS " Print errors to stderr\t\t= ${EASY_OPTION_LOG}")
|
||||||
|
MESSAGE(STATUS "END EASY_PROFILER OPTIONS.----------")
|
||||||
|
MESSAGE(STATUS "")
|
||||||
|
# END EasyProfiler options.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
add_definitions(-DEASY_DEFAULT_PORT=${EASY_DEFAULT_PORT})
|
||||||
|
if(EASY_OPTION_LISTEN)
|
||||||
|
add_definitions(-DEASY_OPTION_START_LISTEN_ON_STARTUP=1)
|
||||||
|
else()
|
||||||
|
add_definitions(-DEASY_OPTION_START_LISTEN_ON_STARTUP=0)
|
||||||
|
endif(EASY_OPTION_LISTEN)
|
||||||
|
|
||||||
|
if(EASY_OPTION_PROFILE_SELF)
|
||||||
|
add_definitions(-DEASY_OPTION_MEASURE_STORAGE_EXPAND=1)
|
||||||
|
if(EASY_OPTION_PROFILE_SELF_BLOCKS_ON)
|
||||||
|
add_definitions(-DEASY_OPTION_STORAGE_EXPAND_BLOCKS_ON=true)
|
||||||
|
else()
|
||||||
|
add_definitions(-DEASY_OPTION_STORAGE_EXPAND_BLOCKS_ON=false)
|
||||||
|
endif(EASY_OPTION_PROFILE_SELF_BLOCKS_ON)
|
||||||
|
else()
|
||||||
|
add_definitions(-DEASY_OPTION_MEASURE_STORAGE_EXPAND=0)
|
||||||
|
endif(EASY_OPTION_PROFILE_SELF)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(EASY_OPTION_EVENT_TRACING)
|
||||||
|
add_definitions(-DEASY_OPTION_EVENT_TRACING_ENABLED=true)
|
||||||
|
else()
|
||||||
|
add_definitions(-DEASY_OPTION_EVENT_TRACING_ENABLED=false)
|
||||||
|
endif(EASY_OPTION_EVENT_TRACING)
|
||||||
|
if(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
|
||||||
|
add_definitions(-DEASY_OPTION_LOW_PRIORITY_EVENT_TRACING=true)
|
||||||
|
else()
|
||||||
|
add_definitions(-DEASY_OPTION_LOW_PRIORITY_EVENT_TRACING=false)
|
||||||
|
endif(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
if(EASY_OPTION_LOG)
|
||||||
|
add_definitions(-DEASY_OPTION_LOG_ENABLED=1)
|
||||||
|
else()
|
||||||
|
add_definitions(-DEASY_OPTION_LOG_ENABLED=0)
|
||||||
|
endif(EASY_OPTION_LOG)
|
||||||
|
|
||||||
set(CPP_FILES
|
set(CPP_FILES
|
||||||
block.cpp
|
block.cpp
|
||||||
profile_manager.cpp
|
profile_manager.cpp
|
||||||
@ -36,33 +132,6 @@ set(INCLUDE_FILES
|
|||||||
)
|
)
|
||||||
source_group(include FILES ${INCLUDE_FILES})
|
source_group(include FILES ${INCLUDE_FILES})
|
||||||
|
|
||||||
|
|
||||||
if(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR)
|
|
||||||
file (STRINGS ${CMAKE_CURRENT_LIST_DIR}/version.info EASY_PRODUCT_VERSION_STRING)
|
|
||||||
string(REPLACE "." ";" VERSION_LIST ${EASY_PRODUCT_VERSION_STRING})
|
|
||||||
|
|
||||||
list(GET VERSION_LIST 0 EASY_PROGRAM_VERSION_MAJOR)
|
|
||||||
list(GET VERSION_LIST 1 EASY_PROGRAM_VERSION_MINOR)
|
|
||||||
list(GET VERSION_LIST 2 EASY_PROGRAM_VERSION_PATCH)
|
|
||||||
|
|
||||||
message(STATUS "EASY_PROGRAM_VERSION_MAJOR: ${EASY_PROGRAM_VERSION_MAJOR}")
|
|
||||||
message(STATUS "EASY_PROGRAM_VERSION_MINOR: ${EASY_PROGRAM_VERSION_MINOR}")
|
|
||||||
message(STATUS "EASY_PROGRAM_VERSION_PATCH: ${EASY_PROGRAM_VERSION_PATCH}")
|
|
||||||
|
|
||||||
# EasyProfiler version
|
|
||||||
add_definitions(
|
|
||||||
-DEASY_PROFILER_VERSION_MAJOR=${EASY_PROGRAM_VERSION_MAJOR}
|
|
||||||
-DEASY_PROFILER_VERSION_MINOR=${EASY_PROGRAM_VERSION_MINOR}
|
|
||||||
-DEASY_PROFILER_VERSION_PATCH=${EASY_PROGRAM_VERSION_PATCH}
|
|
||||||
)
|
|
||||||
# EasyProfiler version
|
|
||||||
|
|
||||||
set(EASY_PROGRAM_VERSION_MAJOR ${EASY_PROGRAM_VERSION_MAJOR} PARENT_SCOPE)
|
|
||||||
set(EASY_PROGRAM_VERSION_MINOR ${EASY_PROGRAM_VERSION_MINOR} PARENT_SCOPE)
|
|
||||||
set(EASY_PROGRAM_VERSION_PATCH ${EASY_PROGRAM_VERSION_PATCH} PARENT_SCOPE)
|
|
||||||
|
|
||||||
endif(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR)
|
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
${CPP_FILES}
|
${CPP_FILES}
|
||||||
${H_FILES}
|
${H_FILES}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#include "event_trace_win.h"
|
#include "event_trace_win.h"
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
|
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ namespace profiler {
|
|||||||
|
|
||||||
EasyEventTracer::EasyEventTracer()
|
EasyEventTracer::EasyEventTracer()
|
||||||
{
|
{
|
||||||
m_lowPriority = ATOMIC_VAR_INIT(EASY_LOW_PRIORITY_EVENT_TRACING);
|
m_lowPriority = ATOMIC_VAR_INIT(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
EasyEventTracer::~EasyEventTracer()
|
EasyEventTracer::~EasyEventTracer()
|
||||||
@ -264,7 +264,7 @@ namespace profiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
if (!success)
|
if (!success)
|
||||||
::std::cerr << "Warning: EasyProfiler failed to set " << _privelegeName << " privelege for the application.\n";
|
::std::cerr << "Warning: EasyProfiler failed to set " << _privelegeName << " privelege for the application.\n";
|
||||||
#endif
|
#endif
|
||||||
@ -283,7 +283,7 @@ namespace profiler {
|
|||||||
HANDLE hToken = nullptr;
|
HANDLE hToken = nullptr;
|
||||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
||||||
{
|
{
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
const bool success = setPrivilege(hToken, SE_DEBUG_NAME);
|
const bool success = setPrivilege(hToken, SE_DEBUG_NAME);
|
||||||
if (!success)
|
if (!success)
|
||||||
::std::cerr << "Warning: Some context switch events could not get process name.\n";
|
::std::cerr << "Warning: Some context switch events could not get process name.\n";
|
||||||
@ -293,7 +293,7 @@ namespace profiler {
|
|||||||
|
|
||||||
CloseHandle(hToken);
|
CloseHandle(hToken);
|
||||||
}
|
}
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::std::cerr << "Warning: EasyProfiler failed to open process to adjust priveleges.\n";
|
::std::cerr << "Warning: EasyProfiler failed to open process to adjust priveleges.\n";
|
||||||
@ -348,26 +348,26 @@ namespace profiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_ALREADY_EXISTS. To stop another session execute cmd: logman stop \"" << KERNEL_LOGGER_NAME << "\" -ets\n";
|
::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_ALREADY_EXISTS. To stop another session execute cmd: logman stop \"" << KERNEL_LOGGER_NAME << "\" -ets\n";
|
||||||
#endif
|
#endif
|
||||||
return EVENT_TRACING_WAS_LAUNCHED_BY_SOMEBODY_ELSE;
|
return EVENT_TRACING_WAS_LAUNCHED_BY_SOMEBODY_ELSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ERROR_ACCESS_DENIED:
|
case ERROR_ACCESS_DENIED:
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_ACCESS_DENIED. Try to launch your application as Administrator.\n";
|
::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_ACCESS_DENIED. Try to launch your application as Administrator.\n";
|
||||||
#endif
|
#endif
|
||||||
return EVENT_TRACING_NOT_ENOUGH_ACCESS_RIGHTS;
|
return EVENT_TRACING_NOT_ENOUGH_ACCESS_RIGHTS;
|
||||||
|
|
||||||
case ERROR_BAD_LENGTH:
|
case ERROR_BAD_LENGTH:
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_BAD_LENGTH. It seems that your KERNEL_LOGGER_NAME differs from \"" << m_properties.sessionName << "\". Try to re-compile easy_profiler or contact EasyProfiler developers.\n";
|
::std::cerr << "Error: EasyProfiler.ETW not launched: ERROR_BAD_LENGTH. It seems that your KERNEL_LOGGER_NAME differs from \"" << m_properties.sessionName << "\". Try to re-compile easy_profiler or contact EasyProfiler developers.\n";
|
||||||
#endif
|
#endif
|
||||||
return EVENT_TRACING_BAD_PROPERTIES_SIZE;
|
return EVENT_TRACING_BAD_PROPERTIES_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
::std::cerr << "Error: EasyProfiler.ETW not launched: StartTrace() returned " << startTraceResult << ::std::endl;
|
::std::cerr << "Error: EasyProfiler.ETW not launched: StartTrace() returned " << startTraceResult << ::std::endl;
|
||||||
#endif
|
#endif
|
||||||
return EVENT_TRACING_MISTERIOUS_ERROR;
|
return EVENT_TRACING_MISTERIOUS_ERROR;
|
||||||
@ -408,7 +408,7 @@ namespace profiler {
|
|||||||
m_openedHandle = OpenTrace(&m_trace);
|
m_openedHandle = OpenTrace(&m_trace);
|
||||||
if (m_openedHandle == INVALID_PROCESSTRACE_HANDLE)
|
if (m_openedHandle == INVALID_PROCESSTRACE_HANDLE)
|
||||||
{
|
{
|
||||||
#if EASY_LOG_ENABLED != 0
|
#if EASY_OPTION_LOG_ENABLED != 0
|
||||||
::std::cerr << "Error: EasyProfiler.ETW not launched: OpenTrace() returned invalid handle.\n";
|
::std::cerr << "Error: EasyProfiler.ETW not launched: OpenTrace() returned invalid handle.\n";
|
||||||
#endif
|
#endif
|
||||||
return EVENT_TRACING_OPEN_TRACE_ERROR;
|
return EVENT_TRACING_OPEN_TRACE_ERROR;
|
||||||
|
@ -206,11 +206,11 @@ This is just for user's comfort. There is no difference for EasyProfiler GUI bet
|
|||||||
|
|
||||||
/** Enable or disable event tracing (context switch events).
|
/** Enable or disable event tracing (context switch events).
|
||||||
|
|
||||||
\note Default value is controlled by EASY_EVENT_TRACING_ENABLED macro.
|
\note Default value is controlled by EASY_OPTION_EVENT_TRACING_ENABLED macro.
|
||||||
|
|
||||||
\note Change will take effect on the next call to EASY_PROFILER_ENABLE.
|
\note Change will take effect on the next call to EASY_PROFILER_ENABLE.
|
||||||
|
|
||||||
\sa EASY_PROFILER_ENABLE, EASY_EVENT_TRACING_ENABLED
|
\sa EASY_PROFILER_ENABLE, EASY_OPTION_EVENT_TRACING_ENABLED
|
||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
@ -227,7 +227,7 @@ Event tracing with normal priority could gather more information about processes
|
|||||||
it could affect performance as it has more work to do. Usually you will not notice any performance
|
it could affect performance as it has more work to do. Usually you will not notice any performance
|
||||||
breakdown, but if you care about that then you change set event tracing priority level to low.
|
breakdown, but if you care about that then you change set event tracing priority level to low.
|
||||||
|
|
||||||
\sa EASY_LOW_PRIORITY_EVENT_TRACING
|
\sa EASY_OPTION_LOW_PRIORITY_EVENT_TRACING
|
||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
@ -239,13 +239,13 @@ breakdown, but if you care about that then you change set event tracing priority
|
|||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_EVENT_TRACING_SET_LOG(filename) ::profiler::setContextSwitchLogFilename(filename);
|
# define EASY_EVENT_TRACING_SET_LOG(filename) ::profiler::setContextSwitchLogFilename(filename);
|
||||||
|
|
||||||
/** Macro returning current path to the temporary log-file for Unix event tracing system.
|
/** Macro returning current path to the temporary log-file for Unix event tracing system.
|
||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_EVENT_TRACING_LOG ::profiler::getContextSwitchLogFilename();
|
# define EASY_EVENT_TRACING_LOG ::profiler::getContextSwitchLogFilename();
|
||||||
|
|
||||||
// EasyProfiler settings:
|
// EasyProfiler settings:
|
||||||
|
|
||||||
@ -257,15 +257,22 @@ These are "EasyProfiler.ExpandStorage" blocks on a diagram.
|
|||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_MEASURE_STORAGE_EXPAND 0
|
# ifndef EASY_OPTION_MEASURE_STORAGE_EXPAND
|
||||||
|
# define EASY_OPTION_MEASURE_STORAGE_EXPAND 0
|
||||||
|
# endif
|
||||||
|
|
||||||
/** If true then "EasyProfiler.ExpandStorage" events are enabled by default and will be
|
# if EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||||
|
/** If true then "EasyProfiler.ExpandStorage" blocks are enabled by default and will be
|
||||||
writed to output file or translated over the net.
|
writed to output file or translated over the net.
|
||||||
If false then you need to enable these events via GUI if you'll want to see them.
|
If false then you need to enable these blocks via GUI if you want to see them.
|
||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_STORAGE_EXPAND_ENABLED true
|
# ifndef EASY_OPTION_STORAGE_EXPAND_BLOCKS_ON
|
||||||
|
# define EASY_OPTION_STORAGE_EXPAND_BLOCKS_ON true
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# endif // EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||||
|
|
||||||
/** If true then EasyProfiler event tracing is enabled by default
|
/** If true then EasyProfiler event tracing is enabled by default
|
||||||
and will be turned on and off when you call profiler::setEnabled().
|
and will be turned on and off when you call profiler::setEnabled().
|
||||||
@ -274,7 +281,9 @@ turned on/off with next calls of profiler::setEnabled().
|
|||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_EVENT_TRACING_ENABLED true
|
# ifndef EASY_OPTION_EVENT_TRACING_ENABLED
|
||||||
|
# define EASY_OPTION_EVENT_TRACING_ENABLED true
|
||||||
|
# endif
|
||||||
|
|
||||||
/** If true then EasyProfiler.ETW thread (Event tracing for Windows) will have low priority by default.
|
/** If true then EasyProfiler.ETW thread (Event tracing for Windows) will have low priority by default.
|
||||||
|
|
||||||
@ -285,7 +294,9 @@ You don't need to rebuild or restart your application for that.
|
|||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_LOW_PRIORITY_EVENT_TRACING true
|
# ifndef EASY_OPTION_LOW_PRIORITY_EVENT_TRACING
|
||||||
|
# define EASY_OPTION_LOW_PRIORITY_EVENT_TRACING true
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
/** If != 0 then EasyProfiler will print error messages into stderr.
|
/** If != 0 then EasyProfiler will print error messages into stderr.
|
||||||
@ -293,8 +304,19 @@ Otherwise, no log messages will be printed.
|
|||||||
|
|
||||||
\ingroup profiler
|
\ingroup profiler
|
||||||
*/
|
*/
|
||||||
# define EASY_LOG_ENABLED 0
|
# ifndef EASY_OPTION_LOG_ENABLED
|
||||||
|
# define EASY_OPTION_LOG_ENABLED 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/** If != 0 then EasyProfiler will start listening thread immidiately on ProfileManager initialization.
|
||||||
|
|
||||||
|
\sa startListen
|
||||||
|
|
||||||
|
\ingroup profiler
|
||||||
|
*/
|
||||||
|
# ifndef EASY_OPTION_START_LISTEN_ON_STARTUP
|
||||||
|
# define EASY_OPTION_START_LISTEN_ON_STARTUP 0
|
||||||
|
# endif
|
||||||
|
|
||||||
#else // #ifdef BUILD_WITH_EASY_PROFILER
|
#else // #ifdef BUILD_WITH_EASY_PROFILER
|
||||||
|
|
||||||
@ -315,14 +337,32 @@ Otherwise, no log messages will be printed.
|
|||||||
# define EASY_EVENT_TRACING_LOG ""
|
# define EASY_EVENT_TRACING_LOG ""
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define EASY_MEASURE_STORAGE_EXPAND 0
|
# ifndef EASY_OPTION_MEASURE_STORAGE_EXPAND
|
||||||
# define EASY_STORAGE_EXPAND_ENABLED false
|
# define EASY_OPTION_MEASURE_STORAGE_EXPAND 0
|
||||||
# define EASY_EVENT_TRACING_ENABLED false
|
# endif
|
||||||
# define EASY_LOW_PRIORITY_EVENT_TRACING true
|
|
||||||
# define EASY_LOG_ENABLED 0
|
# ifndef EASY_OPTION_EVENT_TRACING_ENABLED
|
||||||
|
# define EASY_OPTION_EVENT_TRACING_ENABLED false
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EASY_OPTION_LOW_PRIORITY_EVENT_TRACING
|
||||||
|
# define EASY_OPTION_LOW_PRIORITY_EVENT_TRACING true
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EASY_OPTION_LOG_ENABLED
|
||||||
|
# define EASY_OPTION_LOG_ENABLED 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EASY_OPTION_START_LISTEN_ON_STARTUP
|
||||||
|
# define EASY_OPTION_START_LISTEN_ON_STARTUP 0
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif // #ifndef BUILD_WITH_EASY_PROFILER
|
#endif // #ifndef BUILD_WITH_EASY_PROFILER
|
||||||
|
|
||||||
|
# ifndef EASY_DEFAULT_PORT
|
||||||
|
# define EASY_DEFAULT_PORT 28077
|
||||||
|
# endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -334,7 +374,7 @@ namespace profiler {
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Core types
|
// Core types
|
||||||
|
|
||||||
const uint16_t DEFAULT_PORT = 28077;
|
const uint16_t DEFAULT_PORT = EASY_DEFAULT_PORT;
|
||||||
|
|
||||||
typedef uint64_t timestamp_t;
|
typedef uint64_t timestamp_t;
|
||||||
typedef uint32_t thread_id_t;
|
typedef uint32_t thread_id_t;
|
||||||
|
@ -338,9 +338,9 @@ ThreadStorage::ThreadStorage() : id(getCurrentThreadId()), allowChildren(true),
|
|||||||
|
|
||||||
void ThreadStorage::storeBlock(const profiler::Block& block)
|
void ThreadStorage::storeBlock(const profiler::Block& block)
|
||||||
{
|
{
|
||||||
#if EASY_MEASURE_STORAGE_EXPAND != 0
|
#if EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||||
EASY_LOCAL_STATIC_PTR(const BaseBlockDescriptor*, desc,\
|
EASY_LOCAL_STATIC_PTR(const BaseBlockDescriptor*, desc,\
|
||||||
MANAGER.addBlockDescriptor(EASY_STORAGE_EXPAND_ENABLED ? profiler::ON : profiler::OFF, EASY_UNIQUE_LINE_ID, "EasyProfiler.ExpandStorage",\
|
MANAGER.addBlockDescriptor(EASY_OPTION_STORAGE_EXPAND_BLOCKS_ON ? profiler::ON : profiler::OFF, EASY_UNIQUE_LINE_ID, "EasyProfiler.ExpandStorage",\
|
||||||
__FILE__, __LINE__, profiler::BLOCK_TYPE_BLOCK, profiler::colors::White));
|
__FILE__, __LINE__, profiler::BLOCK_TYPE_BLOCK, profiler::colors::White));
|
||||||
|
|
||||||
EASY_THREAD_LOCAL static profiler::timestamp_t beginTime = 0ULL;
|
EASY_THREAD_LOCAL static profiler::timestamp_t beginTime = 0ULL;
|
||||||
@ -350,21 +350,21 @@ void ThreadStorage::storeBlock(const profiler::Block& block)
|
|||||||
auto name_length = static_cast<uint16_t>(strlen(block.name()));
|
auto name_length = static_cast<uint16_t>(strlen(block.name()));
|
||||||
auto size = static_cast<uint16_t>(sizeof(BaseBlockData) + name_length + 1);
|
auto size = static_cast<uint16_t>(sizeof(BaseBlockData) + name_length + 1);
|
||||||
|
|
||||||
#if EASY_MEASURE_STORAGE_EXPAND != 0
|
#if EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||||
const bool expanded = (desc->m_status & profiler::ON) && blocks.closedList.need_expand(size);
|
const bool expanded = (desc->m_status & profiler::ON) && blocks.closedList.need_expand(size);
|
||||||
if (expanded) beginTime = getCurrentTime();
|
if (expanded) beginTime = getCurrentTime();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto data = blocks.closedList.allocate(size);
|
auto data = blocks.closedList.allocate(size);
|
||||||
|
|
||||||
#if EASY_MEASURE_STORAGE_EXPAND != 0
|
#if EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||||
if (expanded) endTime = getCurrentTime();
|
if (expanded) endTime = getCurrentTime();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
::new (data) SerializedBlock(block, name_length);
|
::new (data) SerializedBlock(block, name_length);
|
||||||
blocks.usedMemorySize += size;
|
blocks.usedMemorySize += size;
|
||||||
|
|
||||||
#if EASY_MEASURE_STORAGE_EXPAND != 0
|
#if EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||||
if (expanded)
|
if (expanded)
|
||||||
{
|
{
|
||||||
profiler::Block b(beginTime, desc->id(), "");
|
profiler::Block b(beginTime, desc->id(), "");
|
||||||
@ -421,9 +421,13 @@ ProfileManager::ProfileManager() :
|
|||||||
, m_endTime(0)
|
, m_endTime(0)
|
||||||
{
|
{
|
||||||
m_isEnabled = ATOMIC_VAR_INIT(false);
|
m_isEnabled = ATOMIC_VAR_INIT(false);
|
||||||
m_isEventTracingEnabled = ATOMIC_VAR_INIT(EASY_EVENT_TRACING_ENABLED);
|
m_isEventTracingEnabled = ATOMIC_VAR_INIT(EASY_OPTION_EVENT_TRACING_ENABLED);
|
||||||
m_isAlreadyListening = ATOMIC_VAR_INIT(false);
|
m_isAlreadyListening = ATOMIC_VAR_INIT(false);
|
||||||
m_stopListen = ATOMIC_VAR_INIT(false);
|
m_stopListen = ATOMIC_VAR_INIT(false);
|
||||||
|
|
||||||
|
#if !defined(EASY_PROFILER_API_DISABLED) && EASY_OPTION_START_LISTEN_ON_STARTUP != 0
|
||||||
|
startListen(profiler::DEFAULT_PORT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileManager::~ProfileManager()
|
ProfileManager::~ProfileManager()
|
||||||
|
@ -458,7 +458,7 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_lastAddress("localhost"), m_lastP
|
|||||||
|
|
||||||
m_eventTracingPriorityAction = submenu->addAction("Low priority event tracing");
|
m_eventTracingPriorityAction = submenu->addAction("Low priority event tracing");
|
||||||
m_eventTracingPriorityAction->setCheckable(true);
|
m_eventTracingPriorityAction->setCheckable(true);
|
||||||
m_eventTracingPriorityAction->setChecked(EASY_LOW_PRIORITY_EVENT_TRACING);
|
m_eventTracingPriorityAction->setChecked(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING);
|
||||||
m_eventTracingPriorityAction->setEnabled(false);
|
m_eventTracingPriorityAction->setEnabled(false);
|
||||||
connect(m_eventTracingPriorityAction, &QAction::triggered, this, &This::onEventTracingPriorityChange);
|
connect(m_eventTracingPriorityAction, &QAction::triggered, this, &This::onEventTracingPriorityChange);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user