diff --git a/CMakeLists.txt b/CMakeLists.txt index 1afaac1..86c1add 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( if(UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -O3" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-reorder -pedantic -O3" ) else() add_definitions( -D_CRT_SECURE_NO_WARNINGS diff --git a/include/profiler/profiler.h b/include/profiler/profiler.h index 76b9669..d2507ef 100644 --- a/include/profiler/profiler.h +++ b/include/profiler/profiler.h @@ -300,16 +300,16 @@ namespace profiler inline const char* getName() const { return name; } }; - class PROFILER_API SerilizedBlock + class PROFILER_API SerializedBlock { uint16_t m_size; char* m_data; public: - SerilizedBlock(profiler::Block* block); - SerilizedBlock(uint16_t _size, char* _data); - SerilizedBlock(SerilizedBlock&& that); - SerilizedBlock(const SerilizedBlock& other); - ~SerilizedBlock(); + SerializedBlock(profiler::Block* block); + SerializedBlock(uint16_t _size, char* _data); + SerializedBlock(SerializedBlock&& that); + SerializedBlock(const SerializedBlock& other); + ~SerializedBlock(); const char* const data() const { return m_data; } uint16_t size() const { return m_size; } diff --git a/include/profiler/reader.h b/include/profiler/reader.h index 9375f3e..f59b0a7 100644 --- a/include/profiler/reader.h +++ b/include/profiler/reader.h @@ -14,78 +14,78 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . -**/ - -#ifndef PROFILER_READER____H -#define PROFILER_READER____H - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include "profiler/profiler.h" - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace profiler { - - typedef uint32_t calls_number_t; - - struct BlockStatistics final - { - ::profiler::timestamp_t total_duration; ///< Summary duration of all block calls - ::profiler::timestamp_t min_duration; ///< Cached block->duration() value. TODO: Remove this if memory consumption will be too high - ::profiler::timestamp_t max_duration; ///< Cached block->duration() value. TODO: Remove this if memory consumption will be too high - unsigned int min_duration_block; ///< Will be used in GUI to jump to the block with min duration - unsigned int max_duration_block; ///< Will be used in GUI to jump to the block with max duration - ::profiler::calls_number_t calls_number; ///< Block calls number - - // TODO: It is better to replace SerilizedBlock* with BlocksTree*, but this requires to store pointers in children list. - - BlockStatistics() - : total_duration(0) - , min_duration(0) - , max_duration(0) - , min_duration_block(0) - , max_duration_block(0) - , calls_number(1) - { - } - - BlockStatistics(::profiler::timestamp_t _duration, unsigned int _block_index) - : total_duration(_duration) - , min_duration(_duration) - , max_duration(_duration) - , min_duration_block(_block_index) - , max_duration_block(_block_index) - , calls_number(1) - { - } - - inline ::profiler::timestamp_t average_duration() const - { - return total_duration / calls_number; - } - - }; // END of struct BlockStatistics. - - inline void release(BlockStatistics*& _stats) - { - if (!_stats) - { - return; - } - - if (--_stats->calls_number == 0) - { - delete _stats; - } - - _stats = nullptr; - } - - ////////////////////////////////////////////////////////////////////////// - +**/ + +#ifndef PROFILER_READER____H +#define PROFILER_READER____H + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include "profiler/profiler.h" + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace profiler { + + typedef uint32_t calls_number_t; + + struct BlockStatistics final + { + ::profiler::timestamp_t total_duration; ///< Summary duration of all block calls + ::profiler::timestamp_t min_duration; ///< Cached block->duration() value. TODO: Remove this if memory consumption will be too high + ::profiler::timestamp_t max_duration; ///< Cached block->duration() value. TODO: Remove this if memory consumption will be too high + unsigned int min_duration_block; ///< Will be used in GUI to jump to the block with min duration + unsigned int max_duration_block; ///< Will be used in GUI to jump to the block with max duration + ::profiler::calls_number_t calls_number; ///< Block calls number + + // TODO: It is better to replace SerilizedBlock* with BlocksTree*, but this requires to store pointers in children list. + + BlockStatistics() + : total_duration(0) + , min_duration(0) + , max_duration(0) + , min_duration_block(0) + , max_duration_block(0) + , calls_number(1) + { + } + + BlockStatistics(::profiler::timestamp_t _duration, unsigned int _block_index) + : total_duration(_duration) + , min_duration(_duration) + , max_duration(_duration) + , min_duration_block(_block_index) + , max_duration_block(_block_index) + , calls_number(1) + { + } + + inline ::profiler::timestamp_t average_duration() const + { + return total_duration / calls_number; + } + + }; // END of struct BlockStatistics. + + inline void release(BlockStatistics*& _stats) + { + if (!_stats) + { + return; + } + + if (--_stats->calls_number == 0) + { + delete _stats; + } + + _stats = nullptr; + } + + ////////////////////////////////////////////////////////////////////////// + class BlocksTree { typedef BlocksTree This; @@ -95,7 +95,7 @@ namespace profiler { typedef ::std::list children_t; children_t children; ///< List of children blocks. May be empty. - ::profiler::SerilizedBlock* node; ///< Pointer to serilized data (type, name, begin, end etc.) + ::profiler::SerializedBlock* node; ///< Pointer to serilized data (type, name, begin, end etc.) ::profiler::BlockStatistics* per_parent_stats; ///< Pointer to statistics for this block within the parent (may be nullptr for top-level blocks) ::profiler::BlockStatistics* per_frame_stats; ///< Pointer to statistics for this block within the frame (may be nullptr for top-level blocks) ::profiler::BlockStatistics* per_thread_stats; ///< Pointer to statistics for this block within the bounds of all frames per current thread diff --git a/profiler_gui/treemodel.cpp b/profiler_gui/treemodel.cpp index f83e83e..32e5fec 100644 --- a/profiler_gui/treemodel.cpp +++ b/profiler_gui/treemodel.cpp @@ -114,7 +114,7 @@ void TreeModel::setupModelData(const QByteArray &lines, TreeItem *parent) indentations << 0; - typedef std::map blocks_map_t; + typedef std::map blocks_map_t; typedef std::map thread_map_t; thread_map_t blocksList; QByteArray array(lines); @@ -131,7 +131,7 @@ void TreeModel::setupModelData(const QByteArray &lines, TreeItem *parent) profiler::BaseBlockData* baseData = (profiler::BaseBlockData*)data; blocksList[baseData->getThreadId()].emplace( baseData->getBegin(), - /*std::move(*/profiler::SerilizedBlock(sz, data))/*)*/; + /*std::move(*/profiler::SerializedBlock(sz, data))/*)*/; } diff --git a/src/profile_manager.cpp b/src/profile_manager.cpp index 69388ec..4b432e2 100644 --- a/src/profile_manager.cpp +++ b/src/profile_manager.cpp @@ -34,7 +34,7 @@ extern "C"{ } } -SerilizedBlock::SerilizedBlock(Block* block): +SerializedBlock::SerializedBlock(Block* block): m_size(0), m_data(nullptr) { @@ -47,7 +47,7 @@ SerilizedBlock::SerilizedBlock(Block* block): strncpy(&m_data[sizeof(BaseBlockData)], block->getName(), name_len); } -SerilizedBlock::SerilizedBlock(uint16_t _size, char* _data) : +SerializedBlock::SerializedBlock(uint16_t _size, char* _data) : m_size(_size), m_data(_data) { @@ -55,7 +55,7 @@ SerilizedBlock::SerilizedBlock(uint16_t _size, char* _data) : //memcpy(&m_data[0], _data, m_size); } -SerilizedBlock::~SerilizedBlock() +SerializedBlock::~SerializedBlock() { if (m_data){ delete[] m_data; @@ -63,14 +63,14 @@ SerilizedBlock::~SerilizedBlock() } } -SerilizedBlock::SerilizedBlock(const SerilizedBlock& other) +SerializedBlock::SerializedBlock(const SerializedBlock& other) { m_size = other.m_size; m_data = new char[m_size]; memcpy(&m_data[0], other.m_data, m_size); } -SerilizedBlock::SerilizedBlock(SerilizedBlock&& that) +SerializedBlock::SerializedBlock(SerializedBlock&& that) { m_size = that.m_size; m_data = that.m_data; @@ -78,12 +78,12 @@ SerilizedBlock::SerilizedBlock(SerilizedBlock&& that) that.m_data = nullptr; } -const BaseBlockData * SerilizedBlock::block() const +const BaseBlockData * SerializedBlock::block() const { return (const BaseBlockData*)m_data; } -const char* SerilizedBlock::getBlockName() const +const char* SerializedBlock::getBlockName() const { return (const char*)&m_data[sizeof(profiler::BaseBlockData)]; } @@ -150,7 +150,7 @@ void ProfileManager::setEnabled(bool isEnable) void ProfileManager::_internalInsertBlock(profiler::Block* _block) { guard_lock_t lock(m_storedSpin); - m_blocks.emplace_back(new SerilizedBlock(_block)); + m_blocks.emplace_back(new SerializedBlock(_block)); } unsigned int ProfileManager::dumpBlocksToFile(const char* filename) @@ -180,6 +180,6 @@ void ProfileManager::setThreadName(const char* name) return; profiler::Block block(name, current_thread_id, 0, profiler::BLOCK_TYPE_THREAD_SIGN); - m_blocks.emplace_back(new SerilizedBlock(&block)); + m_blocks.emplace_back(new SerializedBlock(&block)); m_namedThreades.insert(current_thread_id); } diff --git a/src/profile_manager.h b/src/profile_manager.h index a97b7ab..b76d921 100644 --- a/src/profile_manager.h +++ b/src/profile_manager.h @@ -65,7 +65,7 @@ class ProfileManager void _internalInsertBlock(profiler::Block* _block); - typedef std::list serialized_list_t; + typedef std::list serialized_list_t; serialized_list_t m_blocks; set_of_thread_id m_namedThreades; diff --git a/src/reader.cpp b/src/reader.cpp index c5de762..9d5106f 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -257,7 +257,7 @@ extern "C"{ auto& per_thread_statistics = thread_statistics[block_thread_id]; ::profiler::BlocksTree tree; - tree.node = new ::profiler::SerilizedBlock(sz, data); + tree.node = new ::profiler::SerializedBlock(sz, data); tree.block_index = blocks_counter++; if (::profiler::BLOCK_TYPE_THREAD_SIGN == baseData->getType())