Changeset 4554 in orxonox.OLD for orxonox/trunk/src/subprojects/benchmark.cc
- Timestamp:
- Jun 8, 2005, 1:36:16 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/subprojects/benchmark.cc
r4166 r4554 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 16 16 You should have received a copy of the GNU General Public License 17 17 along with this program; if not, write to the Free Software Foundation, 18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 19 20 20 … … 26 26 27 27 28 #if defined __linux__ 28 #if defined __linux__ 29 29 30 30 #include "list.h" … … 59 59 dt = end - ini; 60 60 61 int type = -1; 62 /* type -1 == all 61 int type = -1; 62 /* type -1 == all 63 63 type 0 == framework 64 64 type 1 == vector … … 69 69 { 70 70 /* framework test*/ 71 71 72 72 printf("Generating Objects:\t\t\t\t\t%i\n", ITERATIONS); 73 73 /* ************WorldEntity class test************** */ … … 75 75 int i = 0; 76 76 unsigned long mittel = 0; 77 78 for(i = 0; i < ITERATIONS; ++i) 79 80 81 82 83 84 85 86 87 77 78 for(i = 0; i < ITERATIONS; ++i) 79 { 80 rdtscl(ini); 81 82 WorldEntity* w = new WorldEntity(); 83 84 rdtscl(end); 85 delete w; 86 mittel += (end - ini - dt); 87 } 88 88 float mi = mittel / (float)ITERATIONS; 89 89 printf(" Generate a WorldEntity object:\t\t%11.2f\n", mi); 90 90 91 91 /* 92 93 94 95 96 97 98 99 100 101 102 103 104 92 mittel = 0; 93 for(i = 0; i < ITERATIONS; ++i) 94 { 95 rdtscl(ini); 96 97 WorldEntity* w = new Primitive(P_SPHERE); 98 99 rdtscl(end); 100 delete w; 101 mittel += (end - ini - dt); 102 } 103 mi = mittel / (float)ITERATIONS; 104 printf(" Generate a Primitive object:\t\t%11.2f\n", mi); 105 105 */ 106 106 107 107 mittel = 0; 108 108 for(i = 0; i < ITERATIONS; ++i) 109 110 111 112 113 114 115 116 117 109 { 110 rdtscl(ini); 111 112 Vector* v = new Vector(); 113 114 rdtscl(end); 115 delete v; 116 mittel += (end - ini - dt); 117 } 118 118 mi = mittel / (float)ITERATIONS; 119 119 printf(" Generate a Vector object:\t\t%11.2f\n", mi); … … 122 122 mittel = 0; 123 123 for(i = 0; i < ITERATIONS; ++i) 124 125 126 127 128 129 130 131 132 124 { 125 rdtscl(ini); 126 127 Quaternion* q = new Quaternion(); 128 129 rdtscl(end); 130 delete q; 131 mittel += (end - ini - dt); 132 } 133 133 mi = mittel / (float)ITERATIONS; 134 134 printf(" Generate a Quaternion object:\t\t%11.2f\n", mi); … … 141 141 w = new WorldEntity(); 142 142 for(i = 0; i < ITERATIONS; ++i) 143 144 145 146 147 148 149 150 143 { 144 rdtscl(ini); 145 146 w->tick(0.0f); 147 148 rdtscl(end); 149 mittel += (end - ini - dt); 150 } 151 151 //delete w; 152 152 mi = mittel / (float)ITERATIONS; … … 157 157 WorldEntity wo; 158 158 for(i = 0; i < ITERATIONS; ++i) 159 160 161 162 163 164 165 166 159 { 160 rdtscl(ini); 161 162 wo.tick(0.0f); 163 164 rdtscl(end); 165 mittel += (end - ini - dt); 166 } 167 167 //delete w; 168 168 mi = mittel / (float)ITERATIONS; 169 169 printf(" Inl virt funct tick() of WE v2: \t%11.2f\n", mi); 170 170 171 171 172 172 mittel = 0; 173 173 BaseObject* bo = new BaseObject(); 174 174 for(i = 0; i < ITERATIONS; ++i) 175 176 177 178 179 180 181 182 175 { 176 rdtscl(ini); 177 178 bo->isFinalized(); 179 180 rdtscl(end); 181 mittel += (end - ini - dt); 182 } 183 183 //delete w; 184 184 mi = mittel / (float)ITERATIONS; 185 185 printf(" Inl funct BaseObject::isFinazlized(): \t%11.2f\n", mi); 186 186 187 187 188 188 tList<WorldEntity>* list = new tList<WorldEntity>(); 189 189 190 190 191 191 /* ************Primitvie class test************** */ 192 192 list = new tList<WorldEntity>(); 193 194 193 194 195 195 /* 196 197 198 199 200 201 202 203 204 205 206 207 208 196 mittel = 0; 197 w = new Primitive(P_SPHERE); 198 for(i = 0; i < ITERATIONS; ++i) 199 { 200 rdtscl(ini); 201 202 w->tick(0.0f); 203 204 rdtscl(end); 205 mittel += (end - ini - dt); 206 } 207 mi = mittel / (float)ITERATIONS; 208 printf(" Call function tick() of Prim:\t\t%11.2f\n", mi); 209 209 */ 210 210 211 211 } 212 212 213 213 if(type == 1 || type == -1) 214 214 { … … 218 218 Vector* b = new Vector(0.4, 2.5, 6.2); 219 219 Vector* c = new Vector(); 220 220 221 221 unsigned long mittel, ini, end; 222 222 float mi; … … 225 225 mittel = 0; 226 226 for(i = 0; i < VECTOR_MAX; ++i) 227 228 229 230 231 232 233 234 227 { 228 rdtscl(ini); 229 230 *c = *a + *b; 231 232 rdtscl(end); 233 mittel += (end - ini - dt); 234 } 235 235 mi = mittel / (float)VECTOR_MAX; 236 236 printf(" Addition of two vectors:\t\t%11.2f\n", mi); 237 237 238 238 // multiplikation 239 239 240 240 mittel = 0; 241 241 for(i = 0; i < VECTOR_MAX; ++i) 242 243 244 245 246 247 248 249 242 { 243 rdtscl(ini); 244 245 *c = a->cross( *b); 246 247 rdtscl(end); 248 mittel += (end - ini - dt); 249 } 250 250 mi = mittel / (float)VECTOR_MAX; 251 251 printf(" CrossMult of two vectors:\t\t%11.2f\n", mi); … … 260 260 Quaternion* b = new Quaternion(); 261 261 Quaternion* c = new Quaternion(); 262 262 263 263 unsigned long mittel, ini, end; 264 264 float mi; … … 269 269 Vector* qb = new Vector(3.5, 6.1, 4.3); 270 270 for(i = 0; i < VECTOR_MAX; ++i) 271 272 273 274 275 276 277 278 279 271 { 272 rdtscl(ini); 273 274 Quaternion* qu = new Quaternion(*qa, *qb); 275 276 rdtscl(end); 277 delete qu; 278 mittel += (end - ini - dt); 279 } 280 280 delete a; 281 281 delete b; 282 282 mi = mittel / (float)VECTOR_MAX; 283 283 printf(" Gen. quatern. betw. two vectors:\t%11.2f\n", mi); 284 285 284 285 286 286 // multiplication 287 287 mittel = 0; 288 288 for(i = 0; i < VECTOR_MAX; ++i) 289 290 291 292 293 294 295 296 289 { 290 rdtscl(ini); 291 292 *c = *a * *b; 293 294 rdtscl(end); 295 mittel += (end - ini - dt); 296 } 297 297 mi = mittel / (float)VECTOR_MAX; 298 298 printf(" Multiplying two quat.(=rot): a * b\t%11.2f\n", mi); 299 300 301 299 300 301 302 302 // rotating a vector by a quaternion 303 303 mittel = 0; 304 304 for(i = 0; i < VECTOR_MAX; ++i) 305 306 307 308 309 310 311 312 305 { 306 rdtscl(ini); 307 308 *qa = a->apply(*qb); 309 310 rdtscl(end); 311 mittel += (end - ini - dt); 312 } 313 313 mi = mittel / (float)VECTOR_MAX; 314 314 printf(" Rot a vec by a quat: q->apply(v)\t%11.2f\n", mi); 315 316 317 315 316 317 318 318 // generate rotation matrix 319 319 mittel = 0; 320 320 float matrix[4][4]; 321 321 for(i = 0; i < VECTOR_MAX; ++i) 322 323 324 325 326 327 328 329 322 { 323 rdtscl(ini); 324 325 a->matrix(matrix); 326 327 rdtscl(end); 328 mittel += (end - ini - dt); 329 } 330 330 mi = mittel / (float)VECTOR_MAX; 331 331 printf(" Generate rot matrix: q->matrix(m)\t%11.2f\n", mi); … … 337 337 tList<char>* list = new tList<char>(); 338 338 char* name; 339 339 340 340 printf(" Adding[1..10] elements to list, found:\n"); 341 341 list->add("1"); … … 349 349 list->add("9"); 350 350 list->add("10"); 351 351 352 352 /*give list out */ 353 353 tIterator<char>* iterator = list->getIterator(); … … 355 355 printf(" List Elements: \t\t"); 356 356 while( name != NULL) 357 358 359 360 357 { 358 printf("%s,", name); 359 name = iterator->nextElement(); 360 } 361 361 delete iterator; 362 362 printf("\n"); 363 364 363 364 365 365 /*removing some elements from the list*/ 366 366 printf(" Removing elements [2,3,6,8,10], adding [11] now found:\n"); … … 376 376 printf(" List Elements: \t\t"); 377 377 while( name != NULL) 378 379 380 381 378 { 379 printf("%s,", name); 380 name = iterator->nextElement(); 381 } 382 382 delete iterator; 383 383 printf("\n"); 384 384 385 385 delete list; 386 386 printf("\nChecking list performance:\t\t\t\t%i\n", LIST_MAX); 387 387 388 388 tList<int>* plist = new tList<int>(); 389 389 unsigned long mittel, ini, end; … … 392 392 mittel = 0; 393 393 for(i = 0; i < LIST_MAX; ++i) 394 395 396 397 398 399 400 401 394 { 395 rdtscl(ini); 396 397 plist->add(&i); 398 399 rdtscl(end); 400 mittel += (end - ini - dt); 401 } 402 402 mi = mittel / (float)LIST_MAX; 403 403 printf(" Adding reference to list:\t\t%11.2f\n", mi); 404 404 405 405 mittel = 0; 406 406 for(i = 0; i < LIST_MAX; ++i) 407 408 409 410 411 412 413 414 407 { 408 rdtscl(ini); 409 410 plist->remove(&i); 411 412 rdtscl(end); 413 mittel += (end - ini - dt); 414 } 415 415 mi = mittel / (float)LIST_MAX; 416 416 printf(" Removing 1st reference from list:\t%11.2f\n", mi); 417 417 418 418 419 419 printf("\nList operations tests: \t\t\t\t\t%i\n", LIST_MAX); … … 430 430 list->add("9"); 431 431 list->add("10"); 432 432 433 433 /*give list out */ 434 434 iterator = list->getIterator(); … … 436 436 printf(" List Elements: \t\t"); 437 437 while( name != NULL) 438 439 440 441 438 { 439 printf("%s,", name); 440 name = iterator->nextElement(); 441 } 442 442 delete iterator; 443 443 printf("\n"); 444 445 444 445 446 446 int c = 0; 447 447 printf(" Going trough list with nextElement(el) func: "); 448 448 name = list->firstElement(); 449 449 while(c < 20) 450 451 452 453 454 450 { 451 printf("%s,", name); 452 name = list->nextElement(name); 453 c++; 454 } 455 455 printf("\n"); 456 457 458 456 457 458 459 459 } 460 460 461 461 } 462 462
Note: See TracChangeset
for help on using the changeset viewer.