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

Merge branch 'serialized_optimize' of https://github.com/yse/easy_profiler into serialized_optimize

This commit is contained in:
Victor Zarubkin 2016-08-21 14:28:09 +03:00
commit 9804378b1a
10 changed files with 35 additions and 22 deletions

View File

@ -360,7 +360,7 @@ namespace profiler
private:
static SerializedBlock* create(const profiler::Block* block, uint64_t& memory_size);
static SerializedBlock* create(const Block &block, uint64_t& memory_size);
static void destroy(SerializedBlock* that);
SerializedBlock(const profiler::Block* block, uint16_t name_length);

View File

@ -32,4 +32,8 @@ add_executable(${PROJECT_NAME}
#treeitem.cpp
)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets easy_profiler)
if(UNIX)
set(SPECIAL_LIB pthread)
endif(UNIX)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets easy_profiler ${SPECIAL_LIB})

View File

@ -1499,6 +1499,12 @@ void EasyGraphicsView::setScrollbar(EasyGraphicsScrollbar* _scrollbar)
disconnect(m_pScrollbar, &EasyGraphicsScrollbar::valueChanged, this, &This::onGraphicsScrollbarValueChange);
}
if(!_scrollbar)
{
qWarning() << "Zero pointer in EasyGraphicsView::setScrollbar(EasyGraphicsScrollbar*): " << __LINE__ << " in file " << __FILE__;
return;
}
m_pScrollbar = _scrollbar;
m_pScrollbar->setMinimapFrom(0, nullptr);
m_pScrollbar->hideChrono();

View File

@ -175,7 +175,7 @@ class EasyChronometerItem : public QGraphicsItem
public:
EasyChronometerItem(bool _main = true);
explicit EasyChronometerItem(bool _main = true);
virtual ~EasyChronometerItem();
// Public virtual methods
@ -284,7 +284,7 @@ private:
public:
EasyGraphicsView(QWidget* _parent = nullptr);
explicit EasyGraphicsView(QWidget* _parent = nullptr);
virtual ~EasyGraphicsView();
// Public virtual methods
@ -412,7 +412,7 @@ private:
public:
EasyGraphicsViewWidget(QWidget* _parent = nullptr);
explicit EasyGraphicsViewWidget(QWidget* _parent = nullptr);
virtual ~EasyGraphicsViewWidget();
EasyGraphicsView* view();

View File

@ -76,7 +76,7 @@ protected:
public:
EasyTreeWidget(QWidget* _parent = nullptr);
explicit EasyTreeWidget(QWidget* _parent = nullptr);
virtual ~EasyTreeWidget();
void clearSilent(bool _global = false);

View File

@ -39,7 +39,7 @@ private:
public:
EasyGraphicsSliderItem(bool _main);
explicit EasyGraphicsSliderItem(bool _main);
virtual ~EasyGraphicsSliderItem();
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget = nullptr) override;
@ -155,7 +155,7 @@ private:
public:
EasyGraphicsScrollbar(QWidget* _parent = nullptr);
explicit EasyGraphicsScrollbar(QWidget* _parent = nullptr);
virtual ~EasyGraphicsScrollbar();
// Public virtual methods

View File

@ -36,12 +36,12 @@ extern "C"{
}
}
SerializedBlock* SerializedBlock::create(const Block* block, uint64_t& memory_size)
SerializedBlock* SerializedBlock::create(const Block& block, uint64_t& memory_size)
{
auto name_length = static_cast<uint16_t>(strlen(block->getName()));
auto name_length = static_cast<uint16_t>(strlen(block.getName()));
auto size = static_cast<uint16_t>(sizeof(BaseBlockData) + name_length + 1);
auto data = ::new char[size];
::new (static_cast<void*>(data)) SerializedBlock(block, name_length);
::new (static_cast<void*>(data)) SerializedBlock(&block, name_length);
memory_size += size;
return reinterpret_cast<SerializedBlock*>(data);
}
@ -93,14 +93,14 @@ ProfileManager& ProfileManager::instance()
void ProfileManager::beginBlock(Block* _block)
{
if (!m_isEnabled)
if (!m_isEnabled || !_block)
return;
if (BLOCK_TYPE_BLOCK == _block->getType()){
guard_lock_t lock(m_spin);
m_openedBracketsMap[_block->getThreadId()].push(_block);
}
else{
_internalInsertBlock(_block);
_internalInsertBlock(*_block);
}
}
@ -120,10 +120,13 @@ void ProfileManager::endBlock()
Block* lastBlock = stackOfOpenedBlocks.top();
if (lastBlock && !lastBlock->isFinished()){
lastBlock->finish();
if (lastBlock )
{
if(!lastBlock->isFinished())
lastBlock->finish();
_internalInsertBlock(*lastBlock);
}
_internalInsertBlock(lastBlock);
stackOfOpenedBlocks.pop();
}
@ -132,7 +135,7 @@ void ProfileManager::setEnabled(bool isEnable)
m_isEnabled = isEnable;
}
void ProfileManager::_internalInsertBlock(profiler::Block* _block)
void ProfileManager::_internalInsertBlock(profiler::Block& _block)
{
guard_lock_t lock(m_storedSpin);
m_blocks.emplace_back(SerializedBlock::create(_block, m_blocksMemorySize));
@ -172,7 +175,7 @@ void ProfileManager::setThreadName(const char* name)
return;
profiler::Block block(name, current_thread_id, 0, profiler::BLOCK_TYPE_THREAD_SIGN);
m_blocks.emplace_back(SerializedBlock::create(&block, m_blocksMemorySize));
m_blocks.emplace_back(SerializedBlock::create(block, m_blocksMemorySize));
m_namedThreades.insert(current_thread_id);
}

View File

@ -65,7 +65,7 @@ class ProfileManager
profiler::spin_lock m_storedSpin;
typedef profiler::guard_lock<profiler::spin_lock> guard_lock_t;
void _internalInsertBlock(profiler::Block* _block);
void _internalInsertBlock(profiler::Block &_block);
sources m_sources;

View File

@ -60,7 +60,7 @@ protected:
public:
cstring(const char* _str) : str(_str), str_len(strlen(_str))
explicit cstring(const char* _str) : str(_str), str_len(strlen(_str))
{
}
@ -105,7 +105,7 @@ public:
size_t str_hash;
hashed_cstr(const char* _str) : Parent(_str), str_hash(0)
explicit hashed_cstr(const char* _str) : Parent(_str), str_hash(0)
{
str_hash = ::std::_Hash_seq((const unsigned char *)str, str_len);
}

View File

@ -48,7 +48,7 @@ namespace profiler{
T& m_mutex;
bool m_isLocked = false;
public:
guard_lock(T& m) :m_mutex(m){
explicit guard_lock(T& m) :m_mutex(m){
m_mutex.lock();
m_isLocked = true;
}