QmlProfiler: option to get statistics from local region

Change-Id: Id11cce971b081d67052dd8e7c74f51e2e25a8fd8
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2011-11-08 16:54:23 +01:00
parent f2544fde4e
commit c4694275fb
8 changed files with 112 additions and 18 deletions

View File

@@ -66,6 +66,10 @@ Rectangle {
signal updateRangeButton
property bool selectionRangeMode: false
property bool selectionRangeReady: selectionRange.ready
property variant selectionRangeStart: selectionRange.startTime
property variant selectionRangeEnd: selectionRange.startTime + selectionRange.duration
// ***** connections with external objects
Connections {
target: zoomControl

View File

@@ -138,6 +138,12 @@ void QmlProfilerEventsWidget::clear()
m_eventParents->clear();
}
void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
{
clear();
m_eventTree->getStatisticsInRange(rangeStart, rangeEnd);
}
QModelIndex QmlProfilerEventsWidget::selectedItem() const
{
return m_eventTree->selectedItem();
@@ -375,6 +381,9 @@ void QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::buildModelFrom
if (visitedFunctionsList.contains(binding))
continue;
if (binding->calls == 0)
continue;
QList<QStandardItem *> newRow;
if (m_fieldShown[Name]) {
newRow << new EventsViewItem(binding->displayname);
@@ -531,6 +540,12 @@ QString QmlProfilerEventsMainView::nameForType(int typeNumber)
return QString();
}
void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
{
d->m_eventStatistics->compileStatistics(rangeStart, rangeEnd);
buildModel();
}
void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
{
QStandardItem *clickedItem = d->m_model->itemFromIndex(index);

View File

@@ -64,6 +64,7 @@ public:
void switchToV8View();
void clear();
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
QModelIndex selectedItem() const;
bool mouseOnTable(const QPoint &position) const;
void copyTableToClipboard() const;
@@ -128,6 +129,8 @@ public:
static QString nameForType(int typeNumber);
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber);
void eventSelected(int eventId);

View File

@@ -182,7 +182,11 @@ void QmlProfilerTool::showContextMenu(const QPoint &position)
QAction *copyRowAction = 0;
QAction *copyTableAction = 0;
QAction *viewAllAction = 0;
QAction *getLocalStatsAction = 0;
QAction *getGlobalStatsAction = 0;
if (eventView && eventView->mouseOnTable(position)) {
menu.addSeparator();
if (eventView->selectedItem().isValid())
copyRowAction = menu.addAction(tr("Copy Row"));
copyTableAction = menu.addAction(tr("Copy Table"));
@@ -195,6 +199,13 @@ void QmlProfilerTool::showContextMenu(const QPoint &position)
}
}
if (sender() == d->m_traceWindow || sender() == d->m_eventsView) {
menu.addSeparator();
if (d->m_traceWindow->hasValidSelection())
getLocalStatsAction = menu.addAction(tr("Get Stats For Current Range"));
getGlobalStatsAction = menu.addAction(tr("Get Global Statistics"));
}
QAction *selectedAction = menu.exec(position);
if (selectedAction) {
@@ -208,6 +219,16 @@ void QmlProfilerTool::showContextMenu(const QPoint &position)
eventView->copyTableToClipboard();
if (selectedAction == viewAllAction)
traceView->viewAll();
if (selectedAction == getLocalStatsAction) {
d->m_eventsView->getStatisticsInRange(
d->m_traceWindow->selectionStart(),
d->m_traceWindow->selectionEnd());
}
if (selectedAction == getGlobalStatsAction) {
d->m_eventsView->getStatisticsInRange(
d->m_traceWindow->getEventList()->traceStartTime(),
d->m_traceWindow->getEventList()->traceEndTime());
}
}
}

View File

@@ -296,6 +296,11 @@ QmlProfilerEventList *TraceWindow::getEventList() const
return m_eventList;
}
ZoomControl *TraceWindow::rangeTimes() const
{
return m_zoomControl.data();
}
void TraceWindow::contextMenuEvent(QContextMenuEvent *ev)
{
emit contextMenuRequested(ev->globalPos());
@@ -434,6 +439,30 @@ void TraceWindow::viewAll()
emit globalZoom();
}
bool TraceWindow::hasValidSelection() const
{
if (m_mainView->rootObject()) {
return m_mainView->rootObject()->property("selectionRangeReady").toBool();
}
return false;
}
qint64 TraceWindow::selectionStart() const
{
if (m_mainView->rootObject()) {
return m_mainView->rootObject()->property("selectionRangeStart").toLongLong();
}
return 0;
}
qint64 TraceWindow::selectionEnd() const
{
if (m_mainView->rootObject()) {
return m_mainView->rootObject()->property("selectionRangeEnd").toLongLong();
}
return 0;
}
void TraceWindow::setZoomLevel(int zoomLevel)
{
if (m_currentZoomLevel != zoomLevel && m_mainView->rootObject()) {

View File

@@ -91,11 +91,15 @@ public:
void reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn);
QmlJsDebugClient::QmlProfilerEventList *getEventList() const;
ZoomControl *rangeTimes() const;
void setRecording(bool recording);
bool isRecording() const;
void viewAll();
bool hasValidSelection() const;
qint64 selectionStart() const;
qint64 selectionEnd() const;
public slots:
void updateCursorPosition();