Changeset 4165 in orxonox.OLD for orxonox/branches/heightMap/src/orxonox.cc
- Timestamp:
- May 11, 2005, 2:23:54 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/heightMap/src/orxonox.cc
r4122 r4165 38 38 #include "text_engine.h" 39 39 #include "factory.h" 40 #include "benchmark.h" 40 41 41 42 #include <string.h> … … 47 48 /** 48 49 \brief create a new Orxonox 50 51 In this funcitons only global values are set. The game will not be started here. 49 52 */ 50 53 Orxonox::Orxonox () … … 55 58 this->resources = NULL; 56 59 this->localinput = NULL; 60 61 this->argc = 0; 62 this->argv = NULL; 57 63 } 58 64 … … 102 108 int Orxonox::init (int argc, char** argv) 103 109 { 110 this->argc = argc; 111 this->argv = argv; 104 112 // parse command line 105 113 // config file … … 131 139 132 140 GraphicsEngine::getInstance(); 133 141 134 142 return 0; 135 143 } … … 219 227 PRINT(3)("initializing TextEngine\n"); 220 228 TextEngine::getInstance(); 229 230 return 0; 221 231 } 222 232 … … 336 346 */ 337 347 int main(int argc, char** argv) 338 { 339 340 /* reading arguments 341 342 currently supported arguments are: 343 <no args> :: just starts orxonox 344 --benchmark :: start the benchmark without starting orxonox 345 346 this is a preselection: it matches to one of the start* functions, the 347 finetuning is made in those functions. 348 */ 349 350 348 { 349 350 // here the pre-arguments are loaded, these are needed to go either to orxonx itself, Help, or Benchmark. 351 351 int i; 352 352 for(i = 1; i < argc; ++i) 353 353 { 354 if(! strcmp( "--help", argv[i]) ) return startHelp();355 else if(! strcmp( "--benchmark", argv[i])) return startBenchmarks();356 else if(! 357 else PRINTF(2)("Orxonox does not understand the arguments %s\n", argv[i]);354 if(! strcmp( "--help", argv[i]) || !strcmp("-h", argv[i])) return startHelp(argc, argv); 355 else if(!strcmp( "--benchmark", argv[i]) || !strcmp("-b", argv[i])) return startBenchmarks(); 356 else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true; 357 // else PRINTF(2)("Orxonox does not understand the arguments %s\n", argv[i]); 358 358 } 359 359 … … 363 363 364 364 365 int startHelp( )365 int startHelp(int argc, char** argv) 366 366 { 367 367 PRINT(0)("orxonox: starts the orxonox game - rules\n"); 368 PRINT(0)("usage: orxonox [arg ]\n\n");368 PRINT(0)("usage: orxonox [arg [arg...]]\n\n"); 369 369 PRINT(0)("valid options:\n"); 370 PRINT(0)(" --benchmark\tstarts the orxonox benchmark\n"); 371 PRINT(0)(" --help \tshows this menu\n"); 372 PRINT(0)(" --gui/-g \tDisplays the Gui on startup\n"); 370 { 371 Gui* gui = new Gui(argc, argv); 372 gui->printHelp(); 373 delete gui; 374 } 375 PRINT(0)(" -b|--benchmark:\t\tstarts the orxonox benchmark\n"); 376 PRINT(0)(" -h|--help:\t\t\tshows this help\n"); 373 377 } 374 378 … … 383 387 if (ResourceManager::isFile("~/.orxonox/orxonox.lock")) 384 388 ResourceManager::deleteFile("~/.orxonox/orxonox.lock"); 385 // char* guiExec = new char[strlen(argv[0])+20];386 // sprintf(guiExec,"%sGui --gui", argv[0]);389 390 // starting the GUI 387 391 Gui* gui = new Gui(argc, argv); 392 gui->startGui(); 393 388 394 if (! gui->startOrxonox) 389 395 return 0; … … 410 416 411 417 } 412 413 #if defined __linux__414 415 #include "list.h"416 #include "world_entity.h"417 #include "vector.h"418 #include "player.h"419 #include "base_object.h"420 421 #include <asm/msr.h>422 #include <linux/timex.h>423 424 425 #define LIST_MAX 1000426 #define VECTOR_MAX 1000000427 #define ITERATIONS 10000428 429 430 int startBenchmarks()431 {432 433 printf("===========================================================\n");434 printf("= BENCHMARKS =\n");435 printf("===========================================================\n");436 printf(" the author is not paying any attention to cacheing effects\n");437 printf(" of the CPU.\n\n");438 printf("[title]\t\t\t\t\t [cycles]\t[loops]\n\n");439 // printf("------------------------------------------------------------\n\n");440 441 // first measure the time overhead:442 unsigned long ini, end, dt, tmp;443 rdtscl(ini); rdtscl(end);444 dt = end - ini;445 446 int type = -1;447 /* type -1 == all448 type 0 == framework449 type 1 == vector450 type 2 == quaternion451 type 3 == lists452 */453 if(type == 0 || type == -1)454 {455 /* framework test*/456 457 printf("Generating Objects:\t\t\t\t\t%i\n", ITERATIONS);458 /* ************WorldEntity class test************** */459 WorldEntity* w = NULL;460 int i = 0;461 unsigned long mittel = 0;462 463 for(i = 0; i < ITERATIONS; ++i)464 {465 rdtscl(ini);466 467 WorldEntity* w = new WorldEntity();468 469 rdtscl(end);470 delete w;471 mittel += (end - ini - dt);472 }473 float mi = mittel / (float)ITERATIONS;474 printf(" Generate a WorldEntity object:\t\t%11.2f\n", mi);475 476 /*477 mittel = 0;478 for(i = 0; i < ITERATIONS; ++i)479 {480 rdtscl(ini);481 482 WorldEntity* w = new Primitive(P_SPHERE);483 484 rdtscl(end);485 delete w;486 mittel += (end - ini - dt);487 }488 mi = mittel / (float)ITERATIONS;489 printf(" Generate a Primitive object:\t\t%11.2f\n", mi);490 */491 492 mittel = 0;493 for(i = 0; i < ITERATIONS; ++i)494 {495 rdtscl(ini);496 497 Vector* v = new Vector();498 499 rdtscl(end);500 delete v;501 mittel += (end - ini - dt);502 }503 mi = mittel / (float)ITERATIONS;504 printf(" Generate a Vector object:\t\t%11.2f\n", mi);505 506 507 mittel = 0;508 for(i = 0; i < ITERATIONS; ++i)509 {510 rdtscl(ini);511 512 Quaternion* q = new Quaternion();513 514 rdtscl(end);515 delete q;516 mittel += (end - ini - dt);517 }518 mi = mittel / (float)ITERATIONS;519 printf(" Generate a Quaternion object:\t\t%11.2f\n", mi);520 521 522 523 524 printf("\nCalling function inline &| virtual, \t\t\t%i\n", ITERATIONS);525 mittel = 0;526 w = new WorldEntity();527 for(i = 0; i < ITERATIONS; ++i)528 {529 rdtscl(ini);530 531 w->tick(0.0f);532 533 rdtscl(end);534 mittel += (end - ini - dt);535 }536 //delete w;537 mi = mittel / (float)ITERATIONS;538 printf(" Virt funct tick() of WE: \t\t%11.2f\n", mi);539 540 541 mittel = 0;542 WorldEntity wo;543 for(i = 0; i < ITERATIONS; ++i)544 {545 rdtscl(ini);546 547 wo.tick(0.0f);548 549 rdtscl(end);550 mittel += (end - ini - dt);551 }552 //delete w;553 mi = mittel / (float)ITERATIONS;554 printf(" Inl virt funct tick() of WE v2: \t%11.2f\n", mi);555 556 557 mittel = 0;558 BaseObject* bo = new BaseObject();559 for(i = 0; i < ITERATIONS; ++i)560 {561 rdtscl(ini);562 563 bo->isFinalized();564 565 rdtscl(end);566 mittel += (end - ini - dt);567 }568 //delete w;569 mi = mittel / (float)ITERATIONS;570 printf(" Inl funct BaseObject::isFinazlized(): \t%11.2f\n", mi);571 572 573 tList<WorldEntity>* list = new tList<WorldEntity>();574 575 576 /* ************Primitvie class test************** */577 list = new tList<WorldEntity>();578 579 580 /*581 mittel = 0;582 w = new Primitive(P_SPHERE);583 for(i = 0; i < ITERATIONS; ++i)584 {585 rdtscl(ini);586 587 w->tick(0.0f);588 589 rdtscl(end);590 mittel += (end - ini - dt);591 }592 mi = mittel / (float)ITERATIONS;593 printf(" Call function tick() of Prim:\t\t%11.2f\n", mi);594 */595 596 }597 598 if(type == 1 || type == -1)599 {600 printf("\nDoing some simple vector operations: \t\t\t%i\n", VECTOR_MAX);601 /* vector test */602 Vector* a = new Vector(1.3, 5.3, 4.1);603 Vector* b = new Vector(0.4, 2.5, 6.2);604 Vector* c = new Vector();605 606 unsigned long mittel, ini, end;607 float mi;608 int i = 0;609 // addition610 mittel = 0;611 for(i = 0; i < VECTOR_MAX; ++i)612 {613 rdtscl(ini);614 615 *c = *a + *b;616 617 rdtscl(end);618 mittel += (end - ini - dt);619 }620 mi = mittel / (float)VECTOR_MAX;621 printf(" Addition of two vectors:\t\t%11.2f\n", mi);622 623 // multiplikation624 625 mittel = 0;626 for(i = 0; i < VECTOR_MAX; ++i)627 {628 rdtscl(ini);629 630 *c = a->cross( *b);631 632 rdtscl(end);633 mittel += (end - ini - dt);634 }635 mi = mittel / (float)VECTOR_MAX;636 printf(" CrossMult of two vectors:\t\t%11.2f\n", mi);637 638 }639 if( type == 2 || type == -1)640 {641 /* quaternion test */642 printf("\nDoing some simple quaternion operations: \t\t%i\n", VECTOR_MAX);643 /* vector test */644 Quaternion* a = new Quaternion();645 Quaternion* b = new Quaternion();646 Quaternion* c = new Quaternion();647 648 unsigned long mittel, ini, end;649 float mi;650 int i = 0;651 // quaternion generieren mit spez konstruktor652 mittel = 0;653 Vector* qa = new Vector(4.6, 9.3, 0.4);654 Vector* qb = new Vector(3.5, 6.1, 4.3);655 for(i = 0; i < VECTOR_MAX; ++i)656 {657 rdtscl(ini);658 659 Quaternion* qu = new Quaternion(*qa, *qb);660 661 rdtscl(end);662 delete qu;663 mittel += (end - ini - dt);664 }665 delete a;666 delete b;667 mi = mittel / (float)VECTOR_MAX;668 printf(" Gen. quatern. betw. two vectors:\t%11.2f\n", mi);669 670 671 // multiplication672 mittel = 0;673 for(i = 0; i < VECTOR_MAX; ++i)674 {675 rdtscl(ini);676 677 *c = *a * *b;678 679 rdtscl(end);680 mittel += (end - ini - dt);681 }682 mi = mittel / (float)VECTOR_MAX;683 printf(" Multiplying two quat.(=rot): a * b\t%11.2f\n", mi);684 685 686 687 // rotating a vector by a quaternion688 mittel = 0;689 for(i = 0; i < VECTOR_MAX; ++i)690 {691 rdtscl(ini);692 693 *qa = a->apply(*qb);694 695 rdtscl(end);696 mittel += (end - ini - dt);697 }698 mi = mittel / (float)VECTOR_MAX;699 printf(" Rot a vec by a quat: q->apply(v)\t%11.2f\n", mi);700 701 702 703 // generate rotation matrix704 mittel = 0;705 float matrix[4][4];706 for(i = 0; i < VECTOR_MAX; ++i)707 {708 rdtscl(ini);709 710 a->matrix(matrix);711 712 rdtscl(end);713 mittel += (end - ini - dt);714 }715 mi = mittel / (float)VECTOR_MAX;716 printf(" Generate rot matrix: q->matrix(m)\t%11.2f\n", mi);717 }718 if( type == 3 || type == -1)719 {720 /* list tests*/721 printf("\nList operations tests: \t\t\t\t\t%i\n", LIST_MAX);722 tList<char>* list = new tList<char>();723 char* name;724 725 printf(" Adding[1..10] elements to list, found:\n");726 list->add("1");727 list->add("2");728 list->add("3");729 list->add("4");730 list->add("5");731 list->add("6");732 list->add("7");733 list->add("8");734 list->add("9");735 list->add("10");736 737 /*give list out */738 tIterator<char>* iterator = list->getIterator();739 name = iterator->nextElement();740 printf(" List Elements: \t\t");741 while( name != NULL)742 {743 printf("%s,", name);744 name = iterator->nextElement();745 }746 delete iterator;747 printf("\n");748 749 750 /*removing some elements from the list*/751 printf(" Removing elements [2,3,6,8,10], adding [11] now found:\n");752 list->remove("2");753 list->remove("3");754 list->remove("6");755 list->remove("8");756 list->remove("10");757 list->add("11");758 /*give list out */759 iterator = list->getIterator();760 name = iterator->nextElement();761 printf(" List Elements: \t\t");762 while( name != NULL)763 {764 printf("%s,", name);765 name = iterator->nextElement();766 }767 delete iterator;768 printf("\n");769 770 delete list;771 printf("\nChecking list performance:\t\t\t\t%i\n", LIST_MAX);772 773 tList<int>* plist = new tList<int>();774 unsigned long mittel, ini, end;775 float mi;776 int i = 0;777 mittel = 0;778 for(i = 0; i < LIST_MAX; ++i)779 {780 rdtscl(ini);781 782 plist->add(&i);783 784 rdtscl(end);785 mittel += (end - ini - dt);786 }787 mi = mittel / (float)LIST_MAX;788 printf(" Adding reference to list:\t\t%11.2f\n", mi);789 790 mittel = 0;791 for(i = 0; i < LIST_MAX; ++i)792 {793 rdtscl(ini);794 795 plist->remove(&i);796 797 rdtscl(end);798 mittel += (end - ini - dt);799 }800 mi = mittel / (float)LIST_MAX;801 printf(" Removing 1st reference from list:\t%11.2f\n", mi);802 803 804 printf("\nList operations tests: \t\t\t\t\t%i\n", LIST_MAX);805 list = new tList<char>();806 printf(" Adding[1..10] elements to list, found:\n");807 list->add("1");808 list->add("2");809 list->add("3");810 list->add("4");811 list->add("5");812 list->add("6");813 list->add("7");814 list->add("8");815 list->add("9");816 list->add("10");817 818 /*give list out */819 iterator = list->getIterator();820 name = iterator->nextElement();821 printf(" List Elements: \t\t");822 while( name != NULL)823 {824 printf("%s,", name);825 name = iterator->nextElement();826 }827 delete iterator;828 printf("\n");829 830 831 int c = 0;832 printf(" Going trough list with nextElement(el) func: ");833 name = list->firstElement();834 while(c < 20)835 {836 printf("%s,", name);837 name = list->nextElement(name);838 c++;839 }840 printf("\n");841 842 843 844 }845 846 }847 848 #else849 850 int startBenchmarks()851 {852 PRINTF(1)("Benchmark is not implemented in this system\n");853 }854 855 #endif
Note: See TracChangeset
for help on using the changeset viewer.