30 #include <gtest/gtest.h>
39 timeval temp_time_struct;
40 gettimeofday(&temp_time_struct,NULL);
41 srand(temp_time_struct.tv_usec);
44 void generate_rand_vectors(
double scale, uint64_t runs, std::vector<double>& xvalues, std::vector<double>& yvalues, std::vector<double>&zvalues)
47 for ( uint64_t i = 0; i < runs ; i++ )
49 xvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
50 yvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
51 zvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
59 TEST(tf_benchmark, canTransformCacheLength0)
63 uint64_t runs = 100000;
68 for (uint64_t i = 0 ; i < runs; i++)
73 double frequency = (double)runs / run_duration.
toSec() ;
74 printf(
"can frequency %.2f KHz\n", frequency / 1000.0);
75 EXPECT_GT( frequency, 10000.0);
79 TEST(tf_benchmark, canTransformCacheLength10000)
83 unsigned int cache_length = 10000;
84 for (
unsigned int i = 0; i < cache_length; i++)
90 uint64_t runs = 100000;
96 for (uint64_t i = 0 ; i < runs; i++)
101 double frequency = (double)runs / run_duration.
toSec() ;
102 printf(
"Worst Case Frequency %.2f KHz\n", frequency / 1000.0);
103 EXPECT_GT( frequency, 10000.0);
107 for (uint64_t i = 0 ; i < runs; i++)
112 frequency = (double)runs / run_duration.
toSec() ;
113 printf(
"Intermediate Case Frequency %.2f KHz\n", frequency / 1000.0);
114 EXPECT_GT( frequency, 10000.0);
118 for (uint64_t i = 0 ; i < runs; i++)
123 frequency = (double)runs / run_duration.
toSec() ;
124 printf(
"Best Case Frequency %.2f KHz\n", frequency / 1000.0);
125 EXPECT_GT( frequency, 10000.0);
128 TEST(tf_benchmark, lookupTransformCacheLength10000)
132 unsigned int cache_length = 10000;
133 for (
unsigned int i = 0; i < cache_length; i++)
139 uint64_t runs = 100000;
145 for (uint64_t i = 0 ; i < runs; i++)
150 double frequency = (double)runs / run_duration.
toSec() ;
151 printf(
"Worst Case Lookup Frequency %.2f KHz\n", frequency / 1000.0);
152 EXPECT_GT( frequency, 10000.0);
156 for (uint64_t i = 0 ; i < runs; i++)
161 frequency = (double)runs / run_duration.
toSec() ;
162 printf(
"Intermediate Case Lookup Frequency %.2f KHz\n", frequency / 1000.0);
163 EXPECT_GT( frequency, 10000.0);
167 for (uint64_t i = 0 ; i < runs; i++)
172 frequency = (double)runs / run_duration.
toSec() ;
173 printf(
"Best Case Lookup Frequency %.2f KHz\n", frequency / 1000.0);
174 EXPECT_GT( frequency, 10000.0);
177 TEST(tf_benchmark, benchmarkExhaustiveSearch)
179 uint64_t runs = 40000;
184 std::vector<double> xvalues(runs), yvalues(runs), zvalues(runs);
185 for ( uint64_t i = 0; i < runs ; i++ )
187 xvalues[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
188 yvalues[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
189 zvalues[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
196 for ( uint64_t i = 0; i < runs ; i++ )
203 outpose.setIdentity();
205 EXPECT_NEAR(outpose.getOrigin().x(), xvalues[i],
epsilon);
206 EXPECT_NEAR(outpose.getOrigin().y(), yvalues[i],
epsilon);
207 EXPECT_NEAR(outpose.getOrigin().z(), zvalues[i],
epsilon);
211 std::cout <<
"TransformExcepion got through!!!!! " << ex.what() << std::endl;
212 bool exception_improperly_thrown =
true;
213 EXPECT_FALSE(exception_improperly_thrown);
219 outpose.setIdentity();
221 EXPECT_NEAR(outpose.getOrigin().x(), 0,
epsilon);
222 EXPECT_NEAR(outpose.getOrigin().y(), 0,
epsilon);
223 EXPECT_NEAR(outpose.getOrigin().z(), 0,
epsilon);
226 double frequency = (double)runs / run_duration.
toSec() ;
227 printf(
"exhaustive search frequency %.2f KHz\n", frequency / 1000.0);
228 EXPECT_GT( frequency, 500.0);
232 int main(
int argc,
char **argv){
234 testing::InitGoogleTest(&argc, argv);
235 return RUN_ALL_TESTS();