MCPcopy Create free account
hub / github.com/MITK/MITK / TestANN

Function TestANN

Modules/ContourModel/Testing/mitkContourModelElementTest.cpp:80–195  ·  view source on GitHub ↗

Test ContourModelElement performance

Source from the content-addressed store, hash-verified

78
79// Test ContourModelElement performance
80static bool TestANN()
81{
82 int64 startJob, stopJob, durationJob;
83
84 int maxNumberPts = 1000;
85
86 // worst case query
87 mitk::Point3D query;
88 query[0] = query[1] = query[2] = -100;
89
90 /*+++++++++++++++++++++++++++++ BruteForce +++++++++++++++++++++++++++++++++++++++++*/
91 std::string fileName = std::string(MITK_TEST_OUTPUT_DIR) + "/Bruteforce-test.csv";
92
93 std::ofstream out(fileName.c_str());
94 if (!out.good())
95 {
96 out.close();
97 return false;
98 }
99
100 std::locale previousLocale(out.getloc());
101 std::locale I("C");
102 out.imbue(I);
103
104 mitk::ContourModelElement::Pointer contour = mitk::ContourModelElement::New();
105
106 for (int step = 0; step < 1000; step++)
107 {
108 for (int i = 0; i < 10; i++)
109 {
110 startJob = GetTimeMs64();
111 mitk::ContourModelElement::VertexType *v = contour->BruteForceGetVertexAt(query, 0.001);
112 stopJob = GetTimeMs64();
113 durationJob = (stopJob - startJob);
114 out << durationJob << ";";
115 }
116 mitk::Point3D p;
117 p[0] = p[1] = p[2] = 1;
118 contour->AddVertex(p, false);
119
120 out << std::endl;
121 }
122 out.close();
123 out.imbue(previousLocale);
124 /*+++++++++++++++++++++++++++++ END BruteForce +++++++++++++++++++++++++++++++++++++++++*/
125
126 /*+++++++++++++++++++++++++++++ ANN +++++++++++++++++++++++++++++++++++++++++*/
127 std::string fileName2 = std::string(MITK_TEST_OUTPUT_DIR) + "/ANN-test.csv";
128
129 std::ofstream out2(fileName2.c_str());
130 if (!out2.good())
131 {
132 out2.close();
133 return false;
134 }
135
136 std::locale previousLocale2(out2.getloc());
137 std::locale I2("C");

Callers 1

Calls 5

GetTimeMs64Function · 0.85
closeMethod · 0.80
BruteForceGetVertexAtMethod · 0.80
NewFunction · 0.50
AddVertexMethod · 0.45

Tested by

no test coverage detected