mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
(GUI) Added possibility to display only frames (top-level blocks) on histogram to be able to find unexpected blocks on top level. Use [Settings] -> [Only frames on histogram]
This commit is contained in:
parent
8c4e26e3ec
commit
43b6d1312b
@ -781,6 +781,26 @@ void EasyHistogramItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
|
||||
m_boundingRect.setRect(x, y, w, h);
|
||||
}
|
||||
|
||||
void EasyHistogramItem::rebuildSource(HistRegime _regime)
|
||||
{
|
||||
if (m_regime == _regime)
|
||||
rebuildSource();
|
||||
}
|
||||
|
||||
void EasyHistogramItem::rebuildSource()
|
||||
{
|
||||
if (m_regime == Hist_Id)
|
||||
{
|
||||
m_regime = Hist_Pointer;
|
||||
setSource(m_threadId, m_blockId);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_regime = Hist_Id;
|
||||
setSource(m_threadId, m_pSource);
|
||||
}
|
||||
}
|
||||
|
||||
void EasyHistogramItem::setSource(::profiler::thread_id_t _thread_id, const ::profiler_gui::EasyItems* _items)
|
||||
{
|
||||
if (m_regime == Hist_Pointer && m_threadId == _thread_id && m_pSource == _items)
|
||||
@ -965,7 +985,7 @@ void EasyHistogramItem::setSource(::profiler::thread_id_t _thread_id, ::profiler
|
||||
m_threadWaitTime = root.wait_time;
|
||||
|
||||
m_bReady.store(false, ::std::memory_order_release);
|
||||
m_workerThread = ::std::thread([this](decltype(root) profiler_thread, ::profiler::block_index_t selected_block)
|
||||
m_workerThread = ::std::thread([this](decltype(root) profiler_thread, ::profiler::block_index_t selected_block, bool _showOnlyTopLevelBlocks)
|
||||
{
|
||||
typedef ::std::vector<::std::pair<::profiler::block_index_t, ::profiler::block_index_t> > Stack;
|
||||
|
||||
@ -994,6 +1014,9 @@ void EasyHistogramItem::setSource(::profiler::thread_id_t _thread_id, ::profiler
|
||||
m_blockTotalDuraion += w;
|
||||
}
|
||||
|
||||
if (_showOnlyTopLevelBlocks)
|
||||
continue;
|
||||
|
||||
stack.push_back(::std::make_pair(frame, 0U));
|
||||
while (!stack.empty())
|
||||
{
|
||||
@ -1080,7 +1103,7 @@ void EasyHistogramItem::setSource(::profiler::thread_id_t _thread_id, ::profiler
|
||||
|
||||
m_bReady.store(true, ::std::memory_order_release);
|
||||
|
||||
}, std::ref(root), EASY_GLOBALS.selected_block);
|
||||
}, std::ref(root), EASY_GLOBALS.selected_block, EASY_GLOBALS.display_only_frames_on_histogram);
|
||||
|
||||
m_timeouts = 3;
|
||||
m_timer.start(WORKER_THREAD_CHECK_INTERVAL);
|
||||
@ -1737,6 +1760,12 @@ EasyGraphicsScrollbar::EasyGraphicsScrollbar(QWidget* _parent)
|
||||
m_histogramItem->onModeChanged();
|
||||
});
|
||||
|
||||
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::displayOnlyFramesOnHistogramChanged, [this]()
|
||||
{
|
||||
if (m_histogramItem->isVisible())
|
||||
m_histogramItem->rebuildSource(EasyHistogramItem::Hist_Id);
|
||||
});
|
||||
|
||||
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::threadNameDecorationChanged, this, &This::onThreadViewChanged);
|
||||
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::hexThreadIdChanged, this, &This::onThreadViewChanged);
|
||||
|
||||
|
@ -141,8 +141,12 @@ class EasyHistogramItem : public QGraphicsItem
|
||||
typedef QGraphicsItem Parent;
|
||||
typedef EasyHistogramItem This;
|
||||
|
||||
public:
|
||||
|
||||
enum HistRegime : uint8_t { Hist_Pointer, Hist_Id };
|
||||
|
||||
private:
|
||||
|
||||
QRectF m_boundingRect;
|
||||
qreal m_topDuration;
|
||||
qreal m_bottomDuration;
|
||||
@ -203,6 +207,8 @@ public:
|
||||
|
||||
void setSource(::profiler::thread_id_t _thread_id, const ::profiler_gui::EasyItems* _items);
|
||||
void setSource(::profiler::thread_id_t _thread_id, ::profiler::block_id_t _block_id);
|
||||
void rebuildSource(HistRegime _regime);
|
||||
void rebuildSource();
|
||||
void validateName();
|
||||
void updateImage();
|
||||
void cancelImageUpdate();
|
||||
|
@ -63,6 +63,8 @@ namespace profiler_gui {
|
||||
|
||||
EasyGlobals& EasyGlobals::instance()
|
||||
{
|
||||
// It's okay even without C++11 "magic statics" feature because first call happens
|
||||
// on application initialization - there is only one thread and no data races occur.
|
||||
static EasyGlobals globals;
|
||||
return globals;
|
||||
}
|
||||
@ -100,6 +102,7 @@ namespace profiler_gui {
|
||||
, highlight_blocks_with_same_id(true)
|
||||
, selecting_block_changes_thread(true)
|
||||
, auto_adjust_histogram_height(true)
|
||||
, display_only_frames_on_histogram(false)
|
||||
, bind_scene_and_tree_expand_status(true)
|
||||
{
|
||||
|
||||
|
@ -199,6 +199,7 @@ namespace profiler_gui {
|
||||
bool highlight_blocks_with_same_id; ///< Highlight all blocks with same id on diagram
|
||||
bool selecting_block_changes_thread; ///< If true then current selected thread will change every time you select block
|
||||
bool auto_adjust_histogram_height; ///< Automatically adjust histogram height to the visible region
|
||||
bool display_only_frames_on_histogram; ///< Display only top-level blocks on histogram when drawing histogram by block id
|
||||
bool bind_scene_and_tree_expand_status; /** \brief If true then items on graphics scene and in the tree (blocks hierarchy) are binded on each other
|
||||
so expanding/collapsing items on scene also expands/collapse items in the tree. */
|
||||
|
||||
|
@ -80,6 +80,7 @@ namespace profiler_gui {
|
||||
void blocksRefreshRequired(bool);
|
||||
void expectedFrameTimeChanged();
|
||||
void autoAdjustHistogramChanged();
|
||||
void displayOnlyFramesOnHistogramChanged();
|
||||
void hierarchyFlagChanged(bool);
|
||||
void threadNameDecorationChanged();
|
||||
void hexThreadIdChanged();
|
||||
|
@ -258,6 +258,8 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_lastAddress("localhost"), m_lastP
|
||||
|
||||
toolbar->addSeparator();
|
||||
auto menu = new QMenu("Settings", this);
|
||||
menu->setToolTipsVisible(true);
|
||||
|
||||
QToolButton* toolButton = new QToolButton(toolbar);
|
||||
toolButton->setIcon(QIcon(":/Settings"));
|
||||
toolButton->setMenu(menu);
|
||||
@ -282,6 +284,17 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_lastAddress("localhost"), m_lastP
|
||||
}
|
||||
|
||||
|
||||
action = menu->addAction("Only frames on histogram");
|
||||
action->setToolTip("Display only top-level blocks on histogram.");
|
||||
action->setCheckable(true);
|
||||
action->setChecked(EASY_GLOBALS.display_only_frames_on_histogram);
|
||||
connect(action, &QAction::triggered, [this](bool _checked)
|
||||
{
|
||||
EASY_GLOBALS.display_only_frames_on_histogram = _checked;
|
||||
emit EASY_GLOBALS.events.displayOnlyFramesOnHistogramChanged();
|
||||
});
|
||||
|
||||
|
||||
menu->addSeparator();
|
||||
auto submenu = menu->addMenu("View");
|
||||
submenu->setToolTipsVisible(true);
|
||||
@ -1270,6 +1283,10 @@ void EasyMainWindow::loadSettings()
|
||||
if (!flag.isNull())
|
||||
EASY_GLOBALS.auto_adjust_histogram_height = flag.toBool();
|
||||
|
||||
flag = settings.value("display_only_frames_on_histogram");
|
||||
if (!flag.isNull())
|
||||
EASY_GLOBALS.display_only_frames_on_histogram = flag.toBool();
|
||||
|
||||
flag = settings.value("use_decorated_thread_name");
|
||||
if (!flag.isNull())
|
||||
EASY_GLOBALS.use_decorated_thread_name = flag.toBool();
|
||||
@ -1347,6 +1364,7 @@ void EasyMainWindow::saveSettingsAndGeometry()
|
||||
settings.setValue("selecting_block_changes_thread", EASY_GLOBALS.selecting_block_changes_thread);
|
||||
settings.setValue("enable_event_indicators", EASY_GLOBALS.enable_event_markers);
|
||||
settings.setValue("auto_adjust_histogram_height", EASY_GLOBALS.auto_adjust_histogram_height);
|
||||
settings.setValue("display_only_frames_on_histogram", EASY_GLOBALS.display_only_frames_on_histogram);
|
||||
settings.setValue("use_decorated_thread_name", EASY_GLOBALS.use_decorated_thread_name);
|
||||
settings.setValue("hex_thread_id", EASY_GLOBALS.hex_thread_id);
|
||||
settings.setValue("enable_statistics", EASY_GLOBALS.enable_statistics);
|
||||
|
Loading…
x
Reference in New Issue
Block a user