summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/tools/llvm-exegesis
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2019-03-22 13:13:12 +0000
committerClement Courbet <courbet@google.com>2019-03-22 13:13:12 +0000
commit28550779638d873cd1a58712c1938349a437fdc0 (patch)
tree4ba6c2fda20ef3066bfe67ac38cca7a51a775191 /llvm/unittests/tools/llvm-exegesis
parentc069d9fd36e12b0626fe04f42f3f78113e8d247a (diff)
downloadbcm5719-llvm-28550779638d873cd1a58712c1938349a437fdc0.tar.gz
bcm5719-llvm-28550779638d873cd1a58712c1938349a437fdc0.zip
[llvm-exegesis] Add clustering test.
Summary: To show that dbscan is insensitive to the order of the points. Subscribers: tschuett, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59693 llvm-svn: 356747
Diffstat (limited to 'llvm/unittests/tools/llvm-exegesis')
-rw-r--r--llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp b/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp
index 6834206ff57..174dd4300c5 100644
--- a/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp
@@ -22,6 +22,11 @@ using testing::Field;
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 @@ TEST(ClusteringTest, Clusters3D) {
// 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 @@ TEST(ClusteringTest, Ordering) {
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
OpenPOWER on IntegriCloud