[PATCH] D59693: [llvm-exegesis] Add clustering test.
Clement Courbet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 06:13:29 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356747: [llvm-exegesis] Add clustering test. (authored by courbet, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D59693?vs=191866&id=191867#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59693/new/
https://reviews.llvm.org/D59693
Files:
llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp
Index: llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp
===================================================================
--- llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp
+++ llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp
@@ -22,6 +22,11 @@
using testing::UnorderedElementsAre;
using testing::UnorderedElementsAreArray;
+static constexpr auto HasPoints = [](const std::vector<int> &Indices) {
+ return Field(&InstructionBenchmarkClustering::Cluster::PointIndices,
+ UnorderedElementsAreArray(Indices));
+};
+
TEST(ClusteringTest, Clusters3D) {
std::vector<InstructionBenchmark> Points(6);
@@ -41,11 +46,6 @@
// Error cluster: points {2}
Points[2].Error = "oops";
- auto HasPoints = [](const std::vector<int> &Indices) {
- return Field(&InstructionBenchmarkClustering::Cluster::PointIndices,
- UnorderedElementsAreArray(Indices));
- };
-
auto Clustering = InstructionBenchmarkClustering::create(Points, 2, 0.25);
ASSERT_TRUE((bool)Clustering);
EXPECT_THAT(Clustering.get().getValidClusters(),
@@ -102,6 +102,38 @@
InstructionBenchmarkClustering::ClusterId::error());
}
+TEST(ClusteringTest, Ordering1) {
+ std::vector<InstructionBenchmark> Points(3);
+
+ Points[0].Measurements = {
+ {"x", 0.0, 0.0}};
+ Points[1].Measurements = {
+ {"x", 1.0, 0.0}};
+ Points[2].Measurements = {
+ {"x", 2.0, 0.0}};
+
+ auto Clustering = InstructionBenchmarkClustering::create(Points, 2, 1.1);
+ ASSERT_TRUE((bool)Clustering);
+ EXPECT_THAT(Clustering.get().getValidClusters(),
+ UnorderedElementsAre(HasPoints({0, 1, 2})));
+}
+
+TEST(ClusteringTest, Ordering2) {
+ std::vector<InstructionBenchmark> Points(3);
+
+ Points[0].Measurements = {
+ {"x", 0.0, 0.0}};
+ Points[1].Measurements = {
+ {"x", 2.0, 0.0}};
+ Points[2].Measurements = {
+ {"x", 1.0, 0.0}};
+
+ auto Clustering = InstructionBenchmarkClustering::create(Points, 2, 1.1);
+ ASSERT_TRUE((bool)Clustering);
+ EXPECT_THAT(Clustering.get().getValidClusters(),
+ UnorderedElementsAre(HasPoints({0, 1, 2})));
+}
+
} // namespace
} // namespace exegesis
} // namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59693.191867.patch
Type: text/x-patch
Size: 2212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190322/c18701da/attachment.bin>
More information about the llvm-commits
mailing list