[llvm] r333181 - [llvm-exegesis] Analysis: Show value extents.
Clement Courbet via llvm-commits
llvm-commits at lists.llvm.org
Thu May 24 05:41:02 PDT 2018
Author: courbet
Date: Thu May 24 05:41:02 2018
New Revision: 333181
URL: http://llvm.org/viewvc/llvm-project?rev=333181&view=rev
Log:
[llvm-exegesis] Analysis: Show value extents.
Summary: Screenshot attached in phabricator.
Reviewers: gchatelet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D47318
Modified:
llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp
llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h
llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp
Modified: llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp?rev=333181&r1=333180&r2=333181&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp Thu May 24 05:41:02 2018
@@ -195,22 +195,30 @@ void Analysis::printSchedClassClustersHt
OS << "<tr><td>";
writeClusterId<kEscapeHtml>(OS, CurrentClusterId);
OS << "</td><td><ul>";
- const auto &ClusterRepresentative =
- Points[PointIds[I]]; // FIXME: average measurements.
+ std::vector<BenchmarkMeasureStats> MeasurementStats(
+ Points[PointIds[I]].Measurements.size());
for (; I < E &&
Clustering_.getClusterIdForPoint(PointIds[I]) == CurrentClusterId;
++I) {
+ const auto &Point = Points[PointIds[I]];
OS << "<li><span class=\"mono\">";
- writeEscaped<kEscapeHtml>(OS, Points[PointIds[I]].Key.OpcodeName);
+ writeEscaped<kEscapeHtml>(OS, Point.Key.OpcodeName);
OS << "</span> <span class=\"mono\">";
- writeEscaped<kEscapeHtml>(OS, Points[PointIds[I]].Key.Config);
+ writeEscaped<kEscapeHtml>(OS, Point.Key.Config);
OS << "</span></li>";
+ for (size_t J = 0, F = Point.Measurements.size(); J < F; ++J) {
+ MeasurementStats[J].push(Point.Measurements[J]);
+ }
}
OS << "</ul></td>";
- for (const auto &Measurement : ClusterRepresentative.Measurements) {
- OS << "<td>";
- writeMeasurementValue<kEscapeHtml>(OS, Measurement.Value);
- OS << "</td>";
+ for (const auto &Stats : MeasurementStats) {
+ OS << "<td class=\"measurement\">";
+ writeMeasurementValue<kEscapeHtml>(OS, Stats.avg());
+ OS << "<br><span class=\"minmax\">[";
+ writeMeasurementValue<kEscapeHtml>(OS, Stats.min());
+ OS << ";";
+ writeMeasurementValue<kEscapeHtml>(OS, Stats.max());
+ OS << "]</span></td>";
}
OS << "</tr>";
}
@@ -321,7 +329,7 @@ void Analysis::printSchedClassDescHtml(c
writeEscaped<kEscapeHtml>(OS, SubtargetInfo_->getSchedModel()
.getProcResource(WPR.ProcResourceIdx)
->Name);
- OS << "</spam>: " << WPR.Cycles << "</li>";
+ OS << "</span>: " << WPR.Cycles << "</li>";
}
OS << "</ul></td>";
OS << "</tr>";
@@ -378,6 +386,12 @@ table.sched-class-desc td {
span.mono {
font-family: monospace;
}
+span.minmax {
+ color: #888;
+}
+td.measurement {
+ text-align: center;
+}
</style>
</head>
)";
Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp?rev=333181&r1=333180&r2=333181&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp Thu May 24 05:41:02 2018
@@ -104,4 +104,14 @@ void InstructionBenchmark::writeYamlOrDi
}
}
+void BenchmarkMeasureStats::push(const BenchmarkMeasure &BM) {
+ if (Key.empty())
+ Key = BM.Key;
+ assert(Key == BM.Key);
+ ++NumValues;
+ SumValues += BM.Value;
+ MaxValue = std::max(MaxValue, BM.Value);
+ MinValue = std::min(MinValue, BM.Value);
+}
+
} // namespace exegesis
Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h?rev=333181&r1=333180&r2=333181&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h Thu May 24 05:41:02 2018
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/YAMLTraits.h"
+#include <limits>
#include <string>
#include <vector>
@@ -61,6 +62,29 @@ struct InstructionBenchmark {
void writeYamlOrDie(const llvm::StringRef Filename);
};
+//------------------------------------------------------------------------------
+// Utilities to work with Benchmark measures.
+
+// A class that measures stats over benchmark measures.
+class BenchmarkMeasureStats {
+public:
+ void push(const BenchmarkMeasure &BM);
+
+ double avg() const {
+ assert(NumValues);
+ return SumValues / NumValues;
+ }
+ double min() const { return MinValue; }
+ double max() const { return MaxValue; }
+
+private:
+ std::string Key;
+ double SumValues = 0.0;
+ int NumValues = 0;
+ double MaxValue = std::numeric_limits<double>::min();
+ double MinValue = std::numeric_limits<double>::max();
+};
+
} // namespace exegesis
#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
Modified: llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp?rev=333181&r1=333180&r2=333181&view=diff
==============================================================================
--- llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp (original)
+++ llvm/trunk/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp Thu May 24 05:41:02 2018
@@ -77,5 +77,15 @@ TEST(BenchmarkResultTest, WriteToAndRead
}
}
+TEST(BenchmarkResultTest, BenchmarkMeasureStats) {
+ BenchmarkMeasureStats Stats;
+ Stats.push(BenchmarkMeasure{"a", 0.5, "debug a"});
+ Stats.push(BenchmarkMeasure{"a", 1.5, "debug a"});
+ Stats.push(BenchmarkMeasure{"a", -1.0, "debug a"});
+ Stats.push(BenchmarkMeasure{"a", 0.0, "debug a"});
+ EXPECT_EQ(Stats.min(), -1.0);
+ EXPECT_EQ(Stats.max(), 1.5);
+ EXPECT_EQ(Stats.avg(), 0.25); // (0.5+1.5-1.0+0.0) / 4
+}
} // namespace
} // namespace exegesis
More information about the llvm-commits
mailing list