Reapply "[llvm-mca] Do not separate iterations with a newline in the timeline view."
This reapplies r329403 with a fix for the floating point rounding issue.
llvm-svn: 329680
diff --git a/llvm/tools/llvm-mca/TimelineView.cpp b/llvm/tools/llvm-mca/TimelineView.cpp
index 9419fe4..840d4db 100644
--- a/llvm/tools/llvm-mca/TimelineView.cpp
+++ b/llvm/tools/llvm-mca/TimelineView.cpp
@@ -72,6 +72,17 @@
LastCycle = std::max(LastCycle, CurrentCycle);
}
+static void printAverageTime(raw_string_ostream &OS, double AverageTime) {
+ // Round to the nearest tenth.
+ OS << format("%.1f", floor((AverageTime * 10) + 0.5)/10);
+ if (AverageTime < 10.0)
+ OS << " ";
+ else if (AverageTime < 100.0)
+ OS << " ";
+ else
+ OS << " ";
+}
+
void TimelineView::printWaitTimeEntry(raw_string_ostream &OS,
const WaitTimeEntry &Entry,
unsigned SourceIndex) const {
@@ -100,27 +111,9 @@
else
OS << Executions << " ";
- OS << format("%.1f", AverageTime1);
- if (AverageTime1 < 10.0)
- OS << " ";
- else if (AverageTime1 < 100.0)
- OS << " ";
- else
- OS << " ";
-
- OS << format("%.1f", AverageTime2);
- if (AverageTime2 < 10.0)
- OS << " ";
- else if (AverageTime2 < 100.0)
- OS << " ";
- else
- OS << " ";
-
- OS << format("%.1f", AverageTime3);
- if (AverageTime3 < 10.0)
- OS << " ";
- else if (AverageTime3 < 100.0)
- OS << ' ';
+ printAverageTime(OS, AverageTime1);
+ printAverageTime(OS, AverageTime2);
+ printAverageTime(OS, AverageTime3);
}
}
@@ -155,7 +148,7 @@
const TimelineViewEntry &Entry,
unsigned Iteration,
unsigned SourceIndex) const {
- if (SourceIndex == 0)
+ if (Iteration == 0 && SourceIndex == 0)
OS << '\n';
OS << '[' << Iteration << ',' << SourceIndex << "]\t";
for (unsigned I = 0, E = Entry.CycleDispatched; I < E; ++I)