Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3648 in orxonox.OLD


Ignore:
Timestamp:
Mar 24, 2005, 12:53:54 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: command arguments added to orxonox exec. you can pass benchmark and write your own benchmarking functions for testing purposes. try ./orxonox —help for more info

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/orxonox.cc

    r3619 r3648  
    268268}
    269269
     270
     271#include "list.h"
     272#include "world_entity.h"
     273#include "vector.h"
     274#include <asm/msr.h>
     275#include <linux/timex.h>
     276
     277
     278#define LIST_MAX 10000
     279#define VECTOR_MAX 1000000
     280#define ITERATIONS 10000
     281
    270282/**
    271283   \brief main function
     
    275287int main(int argc, char** argv)
    276288
     289 
     290  /* reading arguments
     291     
     292     currently supported arguments are:
     293     <no args>                   ::    just starts orxonox
     294     --benchmark                 ::    start the benchmark without starting orxonox
     295     
     296     this is a preselection: it matches to one of the start* functions, the
     297     finetuning is made in those functions.
     298  */
     299
     300
     301  int i;
     302  for(i = 0; i < argc; ++i)
     303    {
     304      if(! strcmp( "--help", argv[i])) return startHelp();
     305      else if(! strcmp( "--benchmark", argv[i])) return startBenchmarks();
     306    }
     307
     308  PRINTF(2)("Orxonox does not understand the arguments");
     309  return startOrxonox(argc, argv);
     310}
     311
     312
     313
     314int startHelp()
     315{
     316  printf("orxonox: starts the orxonox game - rules\n");
     317  printf("usage: orxonox [arg]\n\n");
     318  printf("valid options:\n");
     319  printf(" --benchmark\tstarts the orxonox benchmark\n");
     320  printf(" --help \tshows this menu\n");
     321}
     322
     323int startOrxonox(int argc, char** argv)
     324{
    277325  printf(">>> Starting Orxonox <<<\n");
    278326  Orxonox *orx = Orxonox::getInstance();
     
    288336  //delete orx;
    289337 
    290   return 0;
    291 }
     338}
     339
     340
     341int startBenchmarks()
     342{
     343
     344  printf("===========================================================\n");
     345  printf("=                      BENCHMARKS                         =\n");
     346  printf("===========================================================\n");
     347
     348  // first measure the time overhead:
     349  unsigned long ini, end, dt, tmp;
     350  rdtscl(ini); rdtscl(end);
     351  dt = end - ini;
     352
     353  int type = 0;
     354  /* type   -1 == all
     355     type    0 == framework
     356     type    1 == vector
     357     type    2 == quaternion
     358  */
     359  if(type == 0 || type == -1)
     360    {
     361      /* framework test*/
     362      WorldEntity* w = NULL;
     363      int i = 0;
     364      unsigned long mittel = 0;
     365     
     366      for(i = 0; i < ITERATIONS; ++i)
     367        {
     368          rdtscl(ini);
     369         
     370          WorldEntity* w = new WorldEntity();
     371         
     372          rdtscl(end);
     373          mittel += (end - ini - dt);
     374        }
     375      float mi = mittel / (float)ITERATIONS;
     376      printf("Generate a WorldEntity objec [cycles]t: \t%f\n", mi);
     377     
     378     
     379      mittel = 0;
     380      w = new WorldEntity();
     381      for(i = 0; i < ITERATIONS; ++i)
     382        {
     383          rdtscl(ini);
     384         
     385          w->tick(0.0f);
     386           
     387          rdtscl(end);
     388          mittel += (end - ini - dt);
     389          }
     390      mi = mittel / (float)ITERATIONS;
     391      printf("Call an empty function of WE [cycles]t: \t%f\n", mi);
     392     
     393      tList<WorldEntity>* list = new tList<WorldEntity>();
     394     
     395     
     396      // generating list
     397      for(i = 0; i < LIST_MAX; ++i)
     398        {
     399          w = new WorldEntity();
     400          list->add(w);
     401        }
     402       
     403     
     404        // reuse list
     405      w = list->enumerate();
     406      while( w != NULL)
     407        {
     408          w->tick(0.0f);
     409          w = list->nextElement();
     410        }
     411
     412      }
     413  if(type == 1 || type == -1)
     414    {
     415      /* vector test */
     416      Vector* a = new Vector(1.3, 5.3, 4.1);
     417      Vector* b = new Vector(0.4, 2.5, 6.2);
     418      Vector* c = new Vector();
     419     
     420      int i = 0;
     421      // addition
     422      for(i = 0; i < VECTOR_MAX; ++i)
     423        {
     424          *c = *a + *b;
     425        }
     426     
     427      // multiplikation
     428      for(i = 0; i < VECTOR_MAX; ++i)
     429        {
     430          *c = a->cross( *b);
     431        }
     432      if(type == 1 || type == -1)
     433        {
     434          /* quaternion test */
     435
     436        }
     437     
     438
     439    }
     440}
  • orxonox/trunk/src/orxonox.h

    r3613 r3648  
    7272};
    7373
     74int startHelp(void);
     75int startOrxonox(int argc, char** argv);
     76int startBenchmarks(void);
     77
    7478#endif /* _ORXONOX_H */
    7579
Note: See TracChangeset for help on using the changeset viewer.