From d39fecaac1f755319ad6b9608aa6b298a09b9461 Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:29:37 +0300 Subject: [PATCH 1/7] Clang build --- include/profiler/profiler.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/profiler/profiler.h b/include/profiler/profiler.h index 135ad91..1cd489f 100644 --- a/include/profiler/profiler.h +++ b/include/profiler/profiler.h @@ -26,13 +26,21 @@ along with this program.If not, see . # define EASY_THREAD_LOCAL __declspec(thread) # endif #elif defined(__GNUC__) +#ifndef __clang__ # if (__GNUC__ == 4 && __GNUC_MINOR__ < 8) || (__GNUC__ < 4) // There is no support for C++11 thread_local keyword prior to gcc 4.8. Use __thread instead. # define EASY_THREAD_LOCAL __thread +#endif # endif +#if defined ( __clang__ ) +# if (__clang_major__ == 3 && __clang_minor__ < 3) || (__clang_major__ < 3) +# define EASY_THREAD_LOCAL __thread +#endif #endif -// TODO: Check thread_local support for Clang! +#endif + +// TODO: Check thread local support for clanv earlier than 3.3 #ifndef EASY_THREAD_LOCAL # define EASY_THREAD_LOCAL thread_local From cd395073898510b36914db11e20e63f4da59440d Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:32:14 +0300 Subject: [PATCH 2/7] Replace tab to whitespaces --- CMakeLists.txt | 12 ++++---- include/profiler/profiler.h | 56 ++++++++++++++++++------------------- src/block.cpp | 16 +++++------ src/profile_manager.cpp | 18 ++++++------ src/profile_manager.h | 6 ++-- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3367ed5..78876ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ project(profiling_tool) cmake_minimum_required(VERSION 2.8) set( - ROOT - ${CMAKE_CURRENT_LIST_DIR} + ROOT + ${CMAKE_CURRENT_LIST_DIR} ) set(OUTPUT_DIR @@ -23,16 +23,16 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ) include_directories( - include + include ) if(UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-reorder -pedantic -O3" ) else() - add_definitions( - -D_CRT_SECURE_NO_WARNINGS - ) + add_definitions( + -D_CRT_SECURE_NO_WARNINGS + ) endif(UNIX) add_subdirectory(src) diff --git a/include/profiler/profiler.h b/include/profiler/profiler.h index 1cd489f..3720dfd 100644 --- a/include/profiler/profiler.h +++ b/include/profiler/profiler.h @@ -84,19 +84,19 @@ namespace profiler { /** Macro of beginning of block with custom name and color. \code - #include "profiler/profiler.h" - void foo() - { - // some code ... - if(something){ - EASY_BLOCK("Calling bar()"); // Block with default color - bar(); - } + #include "profiler/profiler.h" + void foo() + { + // some code ... + if(something){ + EASY_BLOCK("Calling bar()"); // Block with default color + bar(); + } else{ EASY_BLOCK("Calling baz()", profiler::colors::Red); // Red block baz(); } - } + } \endcode Block will be automatically completed by destructor. @@ -112,11 +112,11 @@ Block will be automatically completed by destructor. /** Macro of beginning of block with function name and custom color. \code - #include "profiler/profiler.h" - void foo(){ - EASY_FUNCTION(); // Block with name="foo" and default color - //some code... - } + #include "profiler/profiler.h" + void foo(){ + EASY_FUNCTION(); // Block with name="foo" and default color + //some code... + } void bar(){ EASY_FUNCTION(profiler::colors::Green); // Green block with name="bar" @@ -142,12 +142,12 @@ int foo() { // some code ... - int sum = 0; - EASY_BLOCK("Calculating sum"); - for (int i = 0; i < 10; ++i){ - sum += i; - } - EASY_END_BLOCK; + int sum = 0; + EASY_BLOCK("Calculating sum"); + for (int i = 0; i < 10; ++i){ + sum += i; + } + EASY_END_BLOCK; // some antoher code here ... @@ -219,10 +219,10 @@ This is only for user comfort. There is no difference for EasyProfiler GUI betwe #include "profiler/profiler_colors.h" #ifdef _WIN32 -#ifdef _BUILD_PROFILER -#define PROFILER_API __declspec(dllexport) +#ifdef _BUILD_PROFILER +#define PROFILER_API __declspec(dllexport) #else -#define PROFILER_API __declspec(dllimport) +#define PROFILER_API __declspec(dllimport) #endif #else #define PROFILER_API @@ -233,7 +233,7 @@ class ThreadStorage; namespace profiler { - class Block; + class Block; typedef uint64_t timestamp_t; typedef uint32_t thread_id_t; @@ -249,8 +249,8 @@ namespace profiler { BLOCK_TYPES_NUMBER }; typedef BlockType block_type_t; - - extern "C" { + + extern "C" { PROFILER_API block_id_t registerDescription(const char* _name, const char* _filename, int _line, block_type_t _block_type, color_t _color = DefaultBlockColor); PROFILER_API void beginBlock(Block& _block); PROFILER_API void endBlock(); @@ -259,8 +259,8 @@ namespace profiler { PROFILER_API const char* setThreadName(const char* name, const char* filename, const char* _funcname, int line); PROFILER_API void setContextSwitchLogFilename(const char* name); PROFILER_API const char* getContextSwitchLogFilename(); - } - + } + #pragma pack(push,1) class PROFILER_API BaseBlockDescriptor { diff --git a/src/block.cpp b/src/block.cpp index 140f6b6..1fca4cc 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -38,17 +38,17 @@ decltype(LARGE_INTEGER::QuadPart) CPU_FREQUENCY = ([](){ LARGE_INTEGER freq; Que inline timestamp_t getCurrentTime() { #ifdef _WIN32 - //see https://msdn.microsoft.com/library/windows/desktop/dn553408(v=vs.85).aspx - LARGE_INTEGER elapsedMicroseconds; - if (!QueryPerformanceCounter(&elapsedMicroseconds)) - return 0; + //see https://msdn.microsoft.com/library/windows/desktop/dn553408(v=vs.85).aspx + LARGE_INTEGER elapsedMicroseconds; + if (!QueryPerformanceCounter(&elapsedMicroseconds)) + return 0; //elapsedMicroseconds.QuadPart *= 1000000000LL; //elapsedMicroseconds.QuadPart /= CPU_FREQUENCY; - return (timestamp_t)elapsedMicroseconds.QuadPart; + return (timestamp_t)elapsedMicroseconds.QuadPart; #else - std::chrono::time_point time_point; - time_point = std::chrono::time_point_cast(std::chrono::system_clock::now()); - return time_point.time_since_epoch().count(); + std::chrono::time_point time_point; + time_point = std::chrono::time_point_cast(std::chrono::system_clock::now()); + return time_point.time_since_epoch().count(); #endif } diff --git a/src/profile_manager.cpp b/src/profile_manager.cpp index 48dd0e7..3a365e8 100644 --- a/src/profile_manager.cpp +++ b/src/profile_manager.cpp @@ -68,19 +68,19 @@ extern "C" { } PROFILER_API void beginBlock(Block& _block) - { + { MANAGER.beginBlock(_block); - } + } - PROFILER_API uint32_t dumpBlocksToFile(const char* filename) - { + PROFILER_API uint32_t dumpBlocksToFile(const char* filename) + { return MANAGER.dumpBlocksToFile(filename); - } + } PROFILER_API const char* setThreadName(const char* name, const char* filename, const char* _funcname, int line) - { + { return MANAGER.setThreadName(name, filename, _funcname, line); - } + } PROFILER_API void setContextSwitchLogFilename(const char* name) { @@ -175,7 +175,7 @@ ProfileManager::ProfileManager() ProfileManager::~ProfileManager() { - //dumpBlocksToFile("test.prof"); + //dumpBlocksToFile("test.prof"); } ProfileManager& ProfileManager::instance() @@ -249,7 +249,7 @@ void ProfileManager::endContextSwitch(profiler::thread_id_t _thread_id, profiler void ProfileManager::setEnabled(bool isEnable) { - m_isEnabled = isEnable; + m_isEnabled = isEnable; } ////////////////////////////////////////////////////////////////////////// diff --git a/src/profile_manager.h b/src/profile_manager.h index 2408471..4851c59 100644 --- a/src/profile_manager.h +++ b/src/profile_manager.h @@ -182,7 +182,7 @@ class ProfileManager final public: static ProfileManager& instance(); - ~ProfileManager(); + ~ProfileManager(); template uint32_t addBlockDescriptor(TArgs ... _args) @@ -194,8 +194,8 @@ public: } void beginBlock(profiler::Block& _block); - void endBlock(); - void setEnabled(bool isEnable); + void endBlock(); + void setEnabled(bool isEnable); uint32_t dumpBlocksToFile(const char* filename); const char* setThreadName(const char* name, const char* filename, const char* _funcname, int line); From 19d757f2317da297599d7eabf1010ad94d7f25de Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:33:10 +0300 Subject: [PATCH 3/7] gcc warning fix --- profiler_gui/graphics_scrollbar.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/profiler_gui/graphics_scrollbar.cpp b/profiler_gui/graphics_scrollbar.cpp index 10e1d5b..092adc2 100644 --- a/profiler_gui/graphics_scrollbar.cpp +++ b/profiler_gui/graphics_scrollbar.cpp @@ -490,7 +490,6 @@ void EasyGraphicsScrollbar::mouseMoveEvent(QMouseEvent* _event) void EasyGraphicsScrollbar::wheelEvent(QWheelEvent* _event) { - qreal deltaSign = _event->delta() < 0 ? -1 : 1; auto w = m_slider->halfwidth() * (_event->delta() < 0 ? ::profiler_gui::SCALING_COEFFICIENT : ::profiler_gui::SCALING_COEFFICIENT_INV); setValue(mapToScene(_event->pos()).x() - m_minimumValue - w); emit wheeled(w * m_windowScale, _event->delta()); From e1d95e0d3b68462d82ffb5c6d0bb46ee50b73596 Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:37:13 +0300 Subject: [PATCH 4/7] clang some warning fix --- profiler_gui/blocks_graphics_view.cpp | 2 +- profiler_gui/blocks_graphics_view.h | 2 +- profiler_gui/graphics_scrollbar.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/profiler_gui/blocks_graphics_view.cpp b/profiler_gui/blocks_graphics_view.cpp index b920e95..6a9d208 100644 --- a/profiler_gui/blocks_graphics_view.cpp +++ b/profiler_gui/blocks_graphics_view.cpp @@ -84,7 +84,7 @@ const QRgb TIMELINE_BACKGROUND = 0x20303030; const QRgb SELECTED_ITEM_COLOR = 0x000050a0; const QColor CHRONOMETER_COLOR2 = QColor::fromRgba(0x40408040); -const unsigned int TEST_PROGRESSION_BASE = 4; +//const unsigned int TEST_PROGRESSION_BASE = 4; const int FLICKER_INTERVAL = 16; // 60Hz diff --git a/profiler_gui/blocks_graphics_view.h b/profiler_gui/blocks_graphics_view.h index 54a27ef..26d57dc 100644 --- a/profiler_gui/blocks_graphics_view.h +++ b/profiler_gui/blocks_graphics_view.h @@ -211,7 +211,7 @@ public: void setHover(bool _hover); - bool contains(const QPointF& _pos) const; + bool contains(const QPointF& _pos) const override; inline bool hoverIndicator() const { diff --git a/profiler_gui/graphics_scrollbar.cpp b/profiler_gui/graphics_scrollbar.cpp index 092adc2..0cf6c96 100644 --- a/profiler_gui/graphics_scrollbar.cpp +++ b/profiler_gui/graphics_scrollbar.cpp @@ -41,7 +41,7 @@ ////////////////////////////////////////////////////////////////////////// const qreal SCALING_COEFFICIENT = 1.25; -const qreal SCALING_COEFFICIENT_INV = 1.0 / SCALING_COEFFICIENT; +//const qreal SCALING_COEFFICIENT_INV = 1.0 / SCALING_COEFFICIENT; const int DEFAULT_TOP = -40; const int DEFAULT_HEIGHT = 80; const int INDICATOR_SIZE = 8; From 26fe3ca7e00d1a3442520f74b438a2b6421bfe65 Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:40:40 +0300 Subject: [PATCH 5/7] ci clang compiler fix attempt --- src/profile_manager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/profile_manager.h b/src/profile_manager.h index 4851c59..8094f8d 100644 --- a/src/profile_manager.h +++ b/src/profile_manager.h @@ -156,6 +156,8 @@ public: void storeBlock(const profiler::Block& _block); void storeCSwitch(const profiler::Block& _block); void clearClosed(); + + ThreadStorage() = default; }; ////////////////////////////////////////////////////////////////////////// From 9eb02316ba9d5fe30984c7ee23ac509d4bc5688f Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:45:25 +0300 Subject: [PATCH 6/7] ci clang compiler fix attempt number two =) --- src/profile_manager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/profile_manager.h b/src/profile_manager.h index 8094f8d..2a0fb47 100644 --- a/src/profile_manager.h +++ b/src/profile_manager.h @@ -104,6 +104,8 @@ class ThreadStorage final template struct BlocksList final { + BlocksList() = default; + class Stack final { //std::stack m_stack; std::vector m_stack; From 39e68b4adcb62a839b85fa313ebcd3c8cc7713e2 Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 7 Sep 2016 21:50:42 +0300 Subject: [PATCH 7/7] ci clang compiler fix attempt number three =| --- src/profile_manager.h | 81 ++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/src/profile_manager.h b/src/profile_manager.h index 2a0fb47..0259cbb 100644 --- a/src/profile_manager.h +++ b/src/profile_manager.h @@ -97,57 +97,58 @@ public: const uint16_t SIZEOF_CSWITCH = sizeof(profiler::BaseBlockData) + 1; -class ThreadStorage final +typedef std::vector serialized_list_t; + +template +struct BlocksList final { - typedef std::vector serialized_list_t; + BlocksList() = default; - template - struct BlocksList final - { - BlocksList() = default; + class Stack final { + //std::stack m_stack; + std::vector m_stack; - class Stack final { - //std::stack m_stack; - std::vector m_stack; + public: - public: + inline void clear() { m_stack.clear(); } + inline bool empty() const { return m_stack.empty(); } - inline void clear() { m_stack.clear(); } - inline bool empty() const { return m_stack.empty(); } + inline void emplace(profiler::Block& _block) { + //m_stack.emplace(_block); + m_stack.emplace_back(_block); + } - inline void emplace(profiler::Block& _block) { - //m_stack.emplace(_block); - m_stack.emplace_back(_block); - } + template inline void emplace(TArgs ... _args) { + //m_stack.emplace(_args); + m_stack.emplace_back(_args...); + } - template inline void emplace(TArgs ... _args) { - //m_stack.emplace(_args); - m_stack.emplace_back(_args...); - } + inline T& top() { + //return m_stack.top(); + return m_stack.back(); + } - inline T& top() { - //return m_stack.top(); - return m_stack.back(); - } - - inline void pop() { - //m_stack.pop(); - m_stack.pop_back(); - } - }; - - chunk_allocator alloc; - Stack openedList; - serialized_list_t closedList; - uint64_t usedMemorySize = 0; - - void clearClosed() { - serialized_list_t().swap(closedList); - alloc.clear(); - usedMemorySize = 0; + inline void pop() { + //m_stack.pop(); + m_stack.pop_back(); } }; + chunk_allocator alloc; + Stack openedList; + serialized_list_t closedList; + uint64_t usedMemorySize = 0; + + void clearClosed() { + serialized_list_t().swap(closedList); + alloc.clear(); + usedMemorySize = 0; + } +}; + + +class ThreadStorage final +{ public: BlocksList, SIZEOF_CSWITCH * (uint16_t)1024U> blocks;