Skip to content

Commit

Permalink
Calculate and display global duration (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
schulmar committed Feb 1, 2016
1 parent 9c71afc commit 046727f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
26 changes: 18 additions & 8 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ void MainWindow::initGui() {
ui->statusBar->addPermanentWidget(numberOfInstantiationsLabel);

instantiationTimeLabel = new QLabel(this);
instantiationTimeLabel->setToolTip(tr("Total template compilation time"));
ui->statusBar->addPermanentWidget(instantiationTimeLabel);

listDialog = new StringListDialog("Regexp", this);
Expand Down Expand Up @@ -460,10 +459,10 @@ void MainWindow::showGlobalStatistics() {
walker.Apply(nullptr, debugManager->getEntryTarget(), visitor);
auto sum = std::accumulate(std::begin(visitor.counts),
std::end(visitor.counts), 0);
numberOfInstantiationsLabel->setText(tr("# of events: %0").arg(sum));
numberOfInstantiationsLabel->setText(tr("%0 events").arg(sum));
QString tooltip = tr("<table>", "instantiation count tooltip header");
for(std::size_t index = 0; index < visitor.counts.size(); ++index) {
tooltip += tr("<tr><td align=right>%0</td><td>%1s</td>\n",
tooltip += tr("<tr><td align=right>%0</td><td>%1(s)</td>\n",
Templar::TraceEntry::InstantiationKindNames[index],
visitor.counts[index])
.arg(visitor.counts[index])
Expand All @@ -472,11 +471,22 @@ void MainWindow::showGlobalStatistics() {
tooltip += tr("</table>", "instantiation count tooltip footer");
numberOfInstantiationsLabel->setToolTip(tooltip);
using FloatingPointSeconds = std::chrono::duration<double>;
instantiationTimeLabel->setText(tr("t=%0 s").arg(
QString::number(std::chrono::duration_cast<FloatingPointSeconds>(
debugManager->getEntryTarget().getDuration())
.count(),
'g', 3)));
instantiationTimeLabel->setText(
tr("in %0 s")
.arg(QString::number(
std::chrono::duration_cast<FloatingPointSeconds>(
debugManager->getEntryTarget().getChildDurations())
.count(),
'g', 3)));
instantiationTimeLabel->setToolTip(
tr("Total template compilation time (summed durations of top level "
"entries)\n\nThe time from the begin of the first to the end of the "
"last template instantiation was %0 seconds")
.arg(QString::number(
std::chrono::duration_cast<FloatingPointSeconds>(
debugManager->getEntryTarget().getDuration())
.count(),
'g', 3)));
}

void MainWindow::on_actionExit_triggered()
Expand Down
10 changes: 10 additions & 0 deletions traceentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ void TraceEntry::iterator::increment()
}
}

TraceEntry::Duration TraceEntry::getChildDurations() const {
TraceEntry::Duration summedChildDurations{0};
if (!children.empty()) {
for (auto const &child : children) {
summedChildDurations += child->getDuration();
}
}
return summedChildDurations;
}

Templar::TraceEntry::iterator TraceEntry::end() { return iterator(); }

Templar::TraceEntry::iterator TraceEntry::begin() { return iterator(this); }
Expand Down
2 changes: 2 additions & 0 deletions traceentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ struct TraceEntry {
return endTimeStamp - beginTimeStamp;
}

Duration getChildDurations() const;

struct iterator;
static iterator end();
iterator begin();
Expand Down

0 comments on commit 046727f

Please sign in to comment.