0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

Fix typo in SerializedBlock class name

This commit is contained in:
Sergey Yagovtsev 2016-08-07 21:40:23 +03:00
parent cae3ab989e
commit 98a3dd7114
7 changed files with 93 additions and 93 deletions

View File

@ -28,7 +28,7 @@ include_directories(
if(UNIX) if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 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() else()
add_definitions( add_definitions(
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS

View File

@ -300,16 +300,16 @@ namespace profiler
inline const char* getName() const { return name; } inline const char* getName() const { return name; }
}; };
class PROFILER_API SerilizedBlock class PROFILER_API SerializedBlock
{ {
uint16_t m_size; uint16_t m_size;
char* m_data; char* m_data;
public: public:
SerilizedBlock(profiler::Block* block); SerializedBlock(profiler::Block* block);
SerilizedBlock(uint16_t _size, char* _data); SerializedBlock(uint16_t _size, char* _data);
SerilizedBlock(SerilizedBlock&& that); SerializedBlock(SerializedBlock&& that);
SerilizedBlock(const SerilizedBlock& other); SerializedBlock(const SerializedBlock& other);
~SerilizedBlock(); ~SerializedBlock();
const char* const data() const { return m_data; } const char* const data() const { return m_data; }
uint16_t size() const { return m_size; } uint16_t size() const { return m_size; }

View File

@ -14,78 +14,78 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>. along with this program.If not, see <http://www.gnu.org/licenses/>.
**/ **/
#ifndef PROFILER_READER____H #ifndef PROFILER_READER____H
#define PROFILER_READER____H #define PROFILER_READER____H
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <list> #include <list>
#include <map> #include <map>
#include "profiler/profiler.h" #include "profiler/profiler.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace profiler { namespace profiler {
typedef uint32_t calls_number_t; typedef uint32_t calls_number_t;
struct BlockStatistics final struct BlockStatistics final
{ {
::profiler::timestamp_t total_duration; ///< Summary duration of all block calls ::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 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 ::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 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 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 ::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. // TODO: It is better to replace SerilizedBlock* with BlocksTree*, but this requires to store pointers in children list.
BlockStatistics() BlockStatistics()
: total_duration(0) : total_duration(0)
, min_duration(0) , min_duration(0)
, max_duration(0) , max_duration(0)
, min_duration_block(0) , min_duration_block(0)
, max_duration_block(0) , max_duration_block(0)
, calls_number(1) , calls_number(1)
{ {
} }
BlockStatistics(::profiler::timestamp_t _duration, unsigned int _block_index) BlockStatistics(::profiler::timestamp_t _duration, unsigned int _block_index)
: total_duration(_duration) : total_duration(_duration)
, min_duration(_duration) , min_duration(_duration)
, max_duration(_duration) , max_duration(_duration)
, min_duration_block(_block_index) , min_duration_block(_block_index)
, max_duration_block(_block_index) , max_duration_block(_block_index)
, calls_number(1) , calls_number(1)
{ {
} }
inline ::profiler::timestamp_t average_duration() const inline ::profiler::timestamp_t average_duration() const
{ {
return total_duration / calls_number; return total_duration / calls_number;
} }
}; // END of struct BlockStatistics. }; // END of struct BlockStatistics.
inline void release(BlockStatistics*& _stats) inline void release(BlockStatistics*& _stats)
{ {
if (!_stats) if (!_stats)
{ {
return; return;
} }
if (--_stats->calls_number == 0) if (--_stats->calls_number == 0)
{ {
delete _stats; delete _stats;
} }
_stats = nullptr; _stats = nullptr;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class BlocksTree class BlocksTree
{ {
typedef BlocksTree This; typedef BlocksTree This;
@ -95,7 +95,7 @@ namespace profiler {
typedef ::std::list<BlocksTree> children_t; typedef ::std::list<BlocksTree> children_t;
children_t children; ///< List of children blocks. May be empty. 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_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_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 ::profiler::BlockStatistics* per_thread_stats; ///< Pointer to statistics for this block within the bounds of all frames per current thread

View File

@ -114,7 +114,7 @@ void TreeModel::setupModelData(const QByteArray &lines, TreeItem *parent)
indentations << 0; indentations << 0;
typedef std::map<profiler::timestamp_t, profiler::SerilizedBlock> blocks_map_t; typedef std::map<profiler::timestamp_t, profiler::SerializedBlock> blocks_map_t;
typedef std::map<size_t, blocks_map_t> thread_map_t; typedef std::map<size_t, blocks_map_t> thread_map_t;
thread_map_t blocksList; thread_map_t blocksList;
QByteArray array(lines); QByteArray array(lines);
@ -131,7 +131,7 @@ void TreeModel::setupModelData(const QByteArray &lines, TreeItem *parent)
profiler::BaseBlockData* baseData = (profiler::BaseBlockData*)data; profiler::BaseBlockData* baseData = (profiler::BaseBlockData*)data;
blocksList[baseData->getThreadId()].emplace( blocksList[baseData->getThreadId()].emplace(
baseData->getBegin(), baseData->getBegin(),
/*std::move(*/profiler::SerilizedBlock(sz, data))/*)*/; /*std::move(*/profiler::SerializedBlock(sz, data))/*)*/;
} }

View File

@ -34,7 +34,7 @@ extern "C"{
} }
} }
SerilizedBlock::SerilizedBlock(Block* block): SerializedBlock::SerializedBlock(Block* block):
m_size(0), m_size(0),
m_data(nullptr) m_data(nullptr)
{ {
@ -47,7 +47,7 @@ SerilizedBlock::SerilizedBlock(Block* block):
strncpy(&m_data[sizeof(BaseBlockData)], block->getName(), name_len); 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_size(_size),
m_data(_data) m_data(_data)
{ {
@ -55,7 +55,7 @@ SerilizedBlock::SerilizedBlock(uint16_t _size, char* _data) :
//memcpy(&m_data[0], _data, m_size); //memcpy(&m_data[0], _data, m_size);
} }
SerilizedBlock::~SerilizedBlock() SerializedBlock::~SerializedBlock()
{ {
if (m_data){ if (m_data){
delete[] 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_size = other.m_size;
m_data = new char[m_size]; m_data = new char[m_size];
memcpy(&m_data[0], other.m_data, 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_size = that.m_size;
m_data = that.m_data; m_data = that.m_data;
@ -78,12 +78,12 @@ SerilizedBlock::SerilizedBlock(SerilizedBlock&& that)
that.m_data = nullptr; that.m_data = nullptr;
} }
const BaseBlockData * SerilizedBlock::block() const const BaseBlockData * SerializedBlock::block() const
{ {
return (const BaseBlockData*)m_data; return (const BaseBlockData*)m_data;
} }
const char* SerilizedBlock::getBlockName() const const char* SerializedBlock::getBlockName() const
{ {
return (const char*)&m_data[sizeof(profiler::BaseBlockData)]; return (const char*)&m_data[sizeof(profiler::BaseBlockData)];
} }
@ -150,7 +150,7 @@ void ProfileManager::setEnabled(bool isEnable)
void ProfileManager::_internalInsertBlock(profiler::Block* _block) void ProfileManager::_internalInsertBlock(profiler::Block* _block)
{ {
guard_lock_t lock(m_storedSpin); 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) unsigned int ProfileManager::dumpBlocksToFile(const char* filename)
@ -180,6 +180,6 @@ void ProfileManager::setThreadName(const char* name)
return; return;
profiler::Block block(name, current_thread_id, 0, profiler::BLOCK_TYPE_THREAD_SIGN); 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); m_namedThreades.insert(current_thread_id);
} }

View File

@ -65,7 +65,7 @@ class ProfileManager
void _internalInsertBlock(profiler::Block* _block); void _internalInsertBlock(profiler::Block* _block);
typedef std::list<profiler::SerilizedBlock*> serialized_list_t; typedef std::list<profiler::SerializedBlock*> serialized_list_t;
serialized_list_t m_blocks; serialized_list_t m_blocks;
set_of_thread_id m_namedThreades; set_of_thread_id m_namedThreades;

View File

@ -257,7 +257,7 @@ extern "C"{
auto& per_thread_statistics = thread_statistics[block_thread_id]; auto& per_thread_statistics = thread_statistics[block_thread_id];
::profiler::BlocksTree tree; ::profiler::BlocksTree tree;
tree.node = new ::profiler::SerilizedBlock(sz, data); tree.node = new ::profiler::SerializedBlock(sz, data);
tree.block_index = blocks_counter++; tree.block_index = blocks_counter++;
if (::profiler::BLOCK_TYPE_THREAD_SIGN == baseData->getType()) if (::profiler::BLOCK_TYPE_THREAD_SIGN == baseData->getType())