mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-28 01:04:41 +08:00
Added possibility to disable predefined colors palette to reduce binary size when user want to use own colors palette
This commit is contained in:
parent
105d8334e1
commit
227a23c266
@ -34,11 +34,13 @@ 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
|
||||
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
|
||||
set(EASY_OPTION_PREDEFINED_COLORS ON) # Use predefined set of colors (see profiler_colors.h)
|
||||
# If you want to use your own colors palette you can turn this option OFF
|
||||
|
||||
if(WIN32)
|
||||
set(EASY_OPTION_EVENT_TRACING ON) # Enable event tracing by default
|
||||
@ -59,6 +61,7 @@ if(WIN32)
|
||||
endif(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
|
||||
endif(WIN32)
|
||||
MESSAGE(STATUS " Print errors to stderr = ${EASY_OPTION_LOG}")
|
||||
MESSAGE(STATUS " Use EasyProfiler colors palette = ${EASY_OPTION_PREDEFINED_COLORS}")
|
||||
MESSAGE(STATUS "END EASY_PROFILER OPTIONS.----------")
|
||||
MESSAGE(STATUS "")
|
||||
# END EasyProfiler options.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -101,6 +104,12 @@ else()
|
||||
add_definitions(-DEASY_OPTION_LOG_ENABLED=0)
|
||||
endif(EASY_OPTION_LOG)
|
||||
|
||||
if(EASY_OPTION_PREDEFINED_COLORS)
|
||||
add_definitions(-DEASY_OPTION_BUILTIN_COLORS=1)
|
||||
else()
|
||||
add_definitions(-DEASY_OPTION_BUILTIN_COLORS=0)
|
||||
endif(EASY_OPTION_PREDEFINED_COLORS)
|
||||
|
||||
set(CPP_FILES
|
||||
block.cpp
|
||||
profile_manager.cpp
|
||||
|
@ -70,6 +70,7 @@
|
||||
//extern ProfileManager& MANAGER;
|
||||
#define MANAGER ProfileManager::instance()
|
||||
|
||||
extern const ::profiler::color_t EASY_COLOR_INTERNAL_EVENT;
|
||||
::std::atomic_uint64_t TRACING_END_TIME = ATOMIC_VAR_INIT(~0ULL);
|
||||
|
||||
namespace profiler {
|
||||
@ -125,7 +126,7 @@ namespace profiler {
|
||||
if (sizeof(CSwitch) != _traceEvent->UserDataLength)
|
||||
return;
|
||||
|
||||
EASY_FUNCTION(::profiler::colors::White, ::profiler::OFF);
|
||||
EASY_FUNCTION(EASY_COLOR_INTERNAL_EVENT, ::profiler::OFF);
|
||||
|
||||
auto _contextSwitchEvent = reinterpret_cast<CSwitch*>(_traceEvent->UserData);
|
||||
const auto time = static_cast<::profiler::timestamp_t>(_traceEvent->EventHeader.TimeStamp.QuadPart);
|
||||
|
@ -59,7 +59,7 @@ namespace profiler {
|
||||
return (static_cast<color_t>(_alpha) << 24) | (static_cast<color_t>(_red) << 16) | (static_cast<color_t>(_green) << 8) | static_cast<color_t>(_blue);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(EASY_OPTION_BUILTIN_COLORS) || EASY_OPTION_BUILTIN_COLORS != 0
|
||||
// Google Material Design colors
|
||||
// See https://material.google.com/style/color.html
|
||||
|
||||
@ -388,6 +388,9 @@ namespace profiler {
|
||||
const color_t BlueGrey = BlueGrey500;
|
||||
|
||||
const color_t Default = Wheat;
|
||||
#else
|
||||
const color_t Default = 0xffffecb3;
|
||||
#endif // #if !defined(EASY_OPTION_BUILTIN_COLORS) || EASY_OPTION_BUILTIN_COLORS == 0
|
||||
|
||||
} // END of namespace colors.
|
||||
|
||||
|
@ -91,6 +91,11 @@ const uint8_t FORCE_ON_FLAG = profiler::FORCE_ON & ~profiler::ON;
|
||||
decltype(LARGE_INTEGER::QuadPart) const CPU_FREQUENCY = ([](){ LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); return freq.QuadPart; })();
|
||||
#endif
|
||||
|
||||
extern const profiler::color_t EASY_COLOR_INTERNAL_EVENT = 0xffffffff; // profiler::colors::White
|
||||
const profiler::color_t EASY_COLOR_THREAD_END = 0xff212121; // profiler::colors::Dark
|
||||
const profiler::color_t EASY_COLOR_START = 0xff4caf50; // profiler::colors::Green
|
||||
const profiler::color_t EASY_COLOR_END = 0xfff44336; // profiler::colors::Red
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EASY_THREAD_LOCAL static ::ThreadStorage* THREAD_STORAGE = nullptr;
|
||||
@ -347,7 +352,7 @@ void ThreadStorage::storeBlock(const profiler::Block& block)
|
||||
#if EASY_OPTION_MEASURE_STORAGE_EXPAND != 0
|
||||
EASY_LOCAL_STATIC_PTR(const BaseBlockDescriptor*, desc,\
|
||||
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, EASY_COLOR_INTERNAL_EVENT));
|
||||
|
||||
EASY_THREAD_LOCAL static profiler::timestamp_t beginTime = 0ULL;
|
||||
EASY_THREAD_LOCAL static profiler::timestamp_t endTime = 0ULL;
|
||||
@ -407,7 +412,7 @@ ThreadGuard::~ThreadGuard()
|
||||
if (m_id != 0 && THREAD_STORAGE != nullptr && THREAD_STORAGE->id == m_id)
|
||||
{
|
||||
bool isMarked = false;
|
||||
EASY_EVENT_RES(isMarked, "ThreadFinished", profiler::colors::Dark, ::profiler::FORCE_ON);
|
||||
EASY_EVENT_RES(isMarked, "ThreadFinished", EASY_COLOR_THREAD_END, ::profiler::FORCE_ON);
|
||||
THREAD_STORAGE->frame.store(false, std::memory_order_release);
|
||||
THREAD_STORAGE->expired.store(isMarked ? 2 : 1, std::memory_order_release);
|
||||
THREAD_STORAGE = nullptr;
|
||||
@ -895,7 +900,7 @@ uint32_t ProfileManager::dumpBlocksToStream(profiler::OStream& _outputStream, bo
|
||||
}
|
||||
|
||||
if (expired == 1) {
|
||||
EASY_FORCE_EVENT3(t, endtime, "ThreadExpired", profiler::colors::Dark);
|
||||
EASY_FORCE_EVENT3(t, endtime, "ThreadExpired", EASY_COLOR_THREAD_END);
|
||||
++num;
|
||||
}
|
||||
|
||||
@ -1109,7 +1114,7 @@ void ProfileManager::listen(uint16_t _port)
|
||||
socket.listen();
|
||||
socket.accept();
|
||||
|
||||
EASY_EVENT("ClientConnected", profiler::colors::White, profiler::OFF);
|
||||
EASY_EVENT("ClientConnected", EASY_COLOR_INTERNAL_EVENT, profiler::OFF);
|
||||
hasConnect = true;
|
||||
|
||||
#ifdef EASY_DEBUG_NET_PRINT
|
||||
@ -1161,7 +1166,7 @@ void ProfileManager::listen(uint16_t _port)
|
||||
printf("receive REQUEST_START_CAPTURE\n");
|
||||
#endif
|
||||
::profiler::timestamp_t t = 0;
|
||||
EASY_FORCE_EVENT(t, "StartCapture", profiler::colors::Green, profiler::OFF);
|
||||
EASY_FORCE_EVENT(t, "StartCapture", EASY_COLOR_START, profiler::OFF);
|
||||
|
||||
m_dumpSpin.lock();
|
||||
const auto prev = m_profilerStatus.exchange(EASY_PROF_ENABLED, std::memory_order_release);
|
||||
@ -1190,7 +1195,7 @@ void ProfileManager::listen(uint16_t _port)
|
||||
disableEventTracer();
|
||||
m_endTime = time;
|
||||
}
|
||||
EASY_FORCE_EVENT2(m_endTime, "StopCapture", profiler::colors::Red, profiler::OFF);
|
||||
EASY_FORCE_EVENT2(m_endTime, "StopCapture", EASY_COLOR_END, profiler::OFF);
|
||||
|
||||
//TODO
|
||||
//if connection aborted - ignore this part
|
||||
|
Loading…
x
Reference in New Issue
Block a user