summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>2016-10-24 19:52:38 (GMT)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>2016-10-24 19:52:38 (GMT)
commit5fcda87e4cf8d4ae61fe5afb2bde605834d3eda0 (patch)
tree758c5daba78ceab7882e7d2c147fff9ef019a261
parent1eb4b19556bff1e83e42b81dae8f349683074a1a (diff)
Hide call counts if all counts from input are zero
This makes KCachegrind's visualization better for input data where call counts are/can not measured (e.g. sampling data). KCachegrind already does similar things for inclusive cost (ie. hiding any inclusive cost values if all inclusive cost is zero), now this is extended for call counts.
-rw-r--r--libcore/cachegrindloader.cpp3
-rw-r--r--libcore/tracedata.cpp6
-rw-r--r--libcore/tracedata.h3
-rw-r--r--libviews/callgraphview.cpp15
-rw-r--r--libviews/callview.cpp25
-rw-r--r--libviews/callview.h1
-rw-r--r--libviews/coverageview.cpp5
-rw-r--r--libviews/functionselection.cpp15
-rw-r--r--libviews/instritem.cpp10
-rw-r--r--libviews/sourceitem.cpp10
10 files changed, 73 insertions, 20 deletions
diff --git a/libcore/cachegrindloader.cpp b/libcore/cachegrindloader.cpp
index ad0ebc9..16ba1da 100644
--- a/libcore/cachegrindloader.cpp
+++ b/libcore/cachegrindloader.cpp
@@ -1213,6 +1213,7 @@ int CachegrindLoader::loadInternal(TraceData* data,
partCalling,
currentCallCount, line);
fcc->setMax(_data->callMax());
+ _data->updateMaxCallCount(fcc->callCount());
#else
if (hasAddrInfo) {
TraceInstrCall* instrCall;
@@ -1235,6 +1236,7 @@ int CachegrindLoader::loadInternal(TraceData* data,
// update maximum of call cost
_data->callMax()->maxCost(partInstrCall);
+ _data->updateMaxCallCount(partInstrCall->callCount());
}
if (hasLineInfo) {
@@ -1249,6 +1251,7 @@ int CachegrindLoader::loadInternal(TraceData* data,
// update maximum of call cost
_data->callMax()->maxCost(partLineCall);
+ _data->updateMaxCallCount(partLineCall->callCount());
}
#endif
currentCalledFile = 0;
diff --git a/libcore/tracedata.cpp b/libcore/tracedata.cpp
index 22e78de..947fc8c 100644
--- a/libcore/tracedata.cpp
+++ b/libcore/tracedata.cpp
@@ -3496,6 +3496,12 @@ TraceFunctionMap::ConstIterator TraceData::functionEndIterator() const
return _functionMap.end();
}
+// _maxCallCount is maintained globally, and only updated at loading
+void TraceData::updateMaxCallCount(SubCost c)
+{
+ if (_maxCallCount < c)
+ _maxCallCount = c;
+}
void TraceData::resetSourceDirs()
{
diff --git a/libcore/tracedata.h b/libcore/tracedata.h
index c56a704..951dd75 100644
--- a/libcore/tracedata.h
+++ b/libcore/tracedata.h
@@ -1446,6 +1446,8 @@ class TraceData: public ProfileCostArray
const TraceFunctionCycleList& functionCycles() { return _functionCycles; }
ProfileCostArray* callMax() { return &_callMax; }
+ SubCost maxCallCount() { return _maxCallCount; }
+ void updateMaxCallCount(SubCost);
void setCommand(const QString& command) { _command = command; }
QString command() const { return _command; }
@@ -1504,6 +1506,7 @@ class TraceData: public ProfileCostArray
// Max of all costs of calls: This allows to see if the incl. cost can
// be hidden for a cost type, as it is always the same as self cost
ProfileCostArray _callMax;
+ SubCost _maxCallCount;
// cycles
TraceFunctionCycleList _functionCycles;
diff --git a/libviews/callgraphview.cpp b/libviews/callgraphview.cpp
index 5c0d1f6..2e0843e 100644
--- a/libviews/callgraphview.cpp
+++ b/libviews/callgraphview.cpp
@@ -1292,10 +1292,15 @@ CanvasEdgeLabel::CanvasEdgeLabel(CallGraphView* v, CanvasEdge* ce, int x,
else
setText(1, SubCost(e->cost).pretty());
- setPosition(0, DrawParams::TopCenter);
- SubCost count((e->count < 1.0) ? 1.0 : e->count);
- setText(0, QString("%1 x").arg(count.pretty()));
- setPixmap(0, percentagePixmap(25, 10, (int)(inclP+.5), Qt::blue, true));
+ int pixPos = 1;
+ if (((TraceItemView*)_view)->data()->maxCallCount() > 0) {
+ setPosition(0, DrawParams::TopCenter);
+ SubCost count((e->count < 1.0) ? 1.0 : e->count);
+ setText(0, QString("%1 x").arg(count.pretty()));
+ pixPos = 0;
+ setToolTip(QString("%1 (%2)").arg(text(0)).arg(text(1)));
+ }
+ setPixmap(pixPos, percentagePixmap(25, 10, (int)(inclP+.5), Qt::blue, true));
_percentage = inclP;
if (_percentage > 100.0) _percentage = 100.0;
@@ -1310,8 +1315,6 @@ CanvasEdgeLabel::CanvasEdgeLabel(CallGraphView* v, CanvasEdge* ce, int x,
setPixmap(0, p);
#endif
}
-
- setToolTip(QString("%1 (%2)").arg(text(0)).arg(text(1)));
}
void CanvasEdgeLabel::paint(QPainter* p,
diff --git a/libviews/callview.cpp b/libviews/callview.cpp
index 3a01774..ada1ba7 100644
--- a/libviews/callview.cpp
+++ b/libviews/callview.cpp
@@ -290,12 +290,33 @@ void CallView::refresh()
// enabling sorting switches on the indicator, but we want it off
header()->setSortIndicatorShown(false);
// resize to content now (section size still can be interactively changed)
- header()->resizeSections(QHeaderView::ResizeToContents);
+ setCostColumnWidths();
+}
- if (!_eventType2) {
+void CallView::setCostColumnWidths()
+{
+ // inclusive cost columns
+ resizeColumnToContents(0);
+ if (_eventType2)
+ resizeColumnToContents(2);
+ else
setColumnWidth(2, 0);
+
+ if (_data->maxCallCount() == 0) {
+ // hide "per call" columns and call count column
+ setColumnWidth(1, 0);
setColumnWidth(3, 0);
+ setColumnWidth(4, 0);
+ }
+ else {
+ resizeColumnToContents(1);
+ if (_eventType2)
+ resizeColumnToContents(3);
+ else
+ setColumnWidth(3, 0);
+ resizeColumnToContents(4);
}
}
+
#include "callview.moc"
diff --git a/libviews/callview.h b/libviews/callview.h
index 35b6736..c05b2fa 100644
--- a/libviews/callview.h
+++ b/libviews/callview.h
@@ -52,6 +52,7 @@ private:
CostItem* canShow(CostItem*);
void doUpdate(int, bool);
void refresh();
+ void setCostColumnWidths();
bool _showCallers;
};
diff --git a/libviews/coverageview.cpp b/libviews/coverageview.cpp
index 876dd69..7add614 100644
--- a/libviews/coverageview.cpp
+++ b/libviews/coverageview.cpp
@@ -364,6 +364,11 @@ void CoverageView::refresh()
header()->setSortIndicatorShown(false);
// resize to content now (section size still can be interactively changed)
header()->resizeSections(QHeaderView::ResizeToContents);
+
+ if (_data->maxCallCount() == 0) {
+ // hide call count
+ setColumnWidth(_showCallers ? 2 : 3, 0);
+ }
}
#include "coverageview.moc"
diff --git a/libviews/functionselection.cpp b/libviews/functionselection.cpp
index 4d69487..b0e62d6 100644
--- a/libviews/functionselection.cpp
+++ b/libviews/functionselection.cpp
@@ -872,14 +872,17 @@ void FunctionSelection::setCostColumnWidths()
{
functionList->resizeColumnToContents(1);
- if (_eventType && (_eventType->subCost(_data->callMax())>0) ) {
- functionList->resizeColumnToContents(0);
+ // hide call count column if all call counts given are zero
+ if (_data->maxCallCount() > 0)
functionList->resizeColumnToContents(2);
- }
- else {
- functionList->header()->resizeSection(0, 0);
+ else
functionList->header()->resizeSection(2, 0);
- }
+
+ // hide inclusive costs if all inclusive costs given are zero
+ if (_eventType && (_eventType->subCost(_data->callMax())>0) )
+ functionList->resizeColumnToContents(0);
+ else
+ functionList->header()->resizeSection(0, 0);
}
void FunctionSelection::functionHeaderClicked(int col)
diff --git a/libviews/instritem.cpp b/libviews/instritem.cpp
index 19d1741..592be77 100644
--- a/libviews/instritem.cpp
+++ b/libviews/instritem.cpp
@@ -112,9 +112,13 @@ InstrItem::InstrItem(InstrView* iv, QTreeWidgetItem* parent, Addr addr,
SubCost cc = _instrCall->callCount();
QString callStr = " ";
- if (cc==0)
- callStr += QObject::tr("Active call to '%1'")
- .arg(_instrCall->call()->calledName());
+ if (cc==0) {
+ if (((TraceItemView*)_view)->data()->maxCallCount() > 0)
+ callStr += QObject::tr("Active call to '%1'");
+ else
+ callStr += QObject::tr("Call to '%1'");
+ callStr = callStr.arg(_instrCall->call()->calledName());
+ }
else
callStr += QObject::tr("%n call(s) to '%2'", "", (uint64)cc)
.arg(_instrCall->call()->calledName());
diff --git a/libviews/sourceitem.cpp b/libviews/sourceitem.cpp
index 5f1f7d2..6972fb0 100644
--- a/libviews/sourceitem.cpp
+++ b/libviews/sourceitem.cpp
@@ -95,9 +95,13 @@ SourceItem::SourceItem(SourceView* sv, QTreeWidgetItem* parent,
SubCost cc = _lineCall->callCount();
QString callStr = " ";
- if (cc==0)
- callStr += QObject::tr("Active call to '%1'")
- .arg(_lineCall->call()->calledName());
+ if (cc==0) {
+ if (((TraceItemView*)_view)->data()->maxCallCount() > 0)
+ callStr += QObject::tr("Active call to '%1'");
+ else
+ callStr += QObject::tr("Call to '%1'");
+ callStr = callStr.arg(_lineCall->call()->calledName());
+ }
else
callStr += QObject::tr("%n call(s) to '%2'", "", (uint64)cc)
.arg(_lineCall->call()->calledName());