mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
Fix typo in SerializedBlock class name
This commit is contained in:
parent
cae3ab989e
commit
98a3dd7114
@ -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
|
||||
|
@ -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; }
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#ifndef PROFILER_READER____H
|
||||
#define PROFILER_READER____H
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#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 <list>
|
||||
#include <map>
|
||||
#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<BlocksTree> 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
|
||||
|
@ -114,7 +114,7 @@ void TreeModel::setupModelData(const QByteArray &lines, TreeItem *parent)
|
||||
|
||||
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;
|
||||
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))/*)*/;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class ProfileManager
|
||||
|
||||
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;
|
||||
|
||||
set_of_thread_id m_namedThreades;
|
||||
|
@ -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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user