Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3661 in orxonox.OLD


Ignore:
Timestamp:
Mar 29, 2005, 10:34:25 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some changes in the benchmark routines and in the list. list is now more efficent than ever and is integrated in the benchmark system.

Location:
orxonox/trunk/src
Files:
5 edited

Legend:

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

    r3647 r3661  
    8888  WorldInterface* wi = WorldInterface::getInstance();
    8989  tList<WorldEntity>* list = wi->getEntityList();
    90   //WorldEntity* entity = list->enumerate();
    91  // while( entity != NULL)
    92   //  {
    93   //  if( entity->isFinalized())
    94   //{
    95   //  PRINTF(3)("Finalizing object in list - not yet done realy\n");
     90
     91  tIterator<WorldEntity>* iterator = list->getIterator();
     92  WorldEntity* entity = iterator->nextElement();
     93  while( entity != NULL)
     94    {
     95      if( entity->isFinalized())
     96        {
     97          PRINTF(3)("Finalizing object in list - not yet done realy\n");
    9698          /* first remove out of entity list */
    9799          //list->remove(entity);
    98100          /* second remove out of pnode tree */
    99           //NullParent* np = NullParent::getInstance();
     101          //llParent* np = NullParent::getInstance();
    100102          //np->removeChild(np);
    101103         
    102   //}
    103   //   entity = list->nextElement();
    104   //}
     104        }
     105      entity = iterator->nextElement();
     106    }
    105107 
    106108  /* reset time to count again up to this->delay */
  • orxonox/trunk/src/lib/util/list.h

    r3654 r3661  
    6666  listElement<T>* currentEl;
    6767  listElement<T>* firstEl;
     68  int counter;
    6869};
    6970
     
    7475  this->currentEl = startElement;
    7576  this->firstEl = startElement;
     77  this->counter = -1;
    7678}
    7779
     
    8789inline T* tIterator<T>::nextElement ()
    8890{
    89   if( this->currentEl == NULL || this->currentEl->next == NULL) /* don't turn it the other way or it will give segfaults! */
    90       return NULL;
    91   if( this->currentEl == this->firstEl)
    92     {
    93       this->currentEl = this->currentEl->next;
    94       return this->firstEl->curr; /* if its the first element, don't return second element*/
    95     }
     91  this->counter++;
     92  if( this->counter == 0)
     93    return this->firstEl->curr;
     94 
     95  if( this->currentEl->next == NULL || this->currentEl == NULL)
     96    return NULL;
     97
    9698  this->currentEl = this->currentEl->next;
    9799  return this->currentEl->curr;
     
    154156
    155157template<class T>
    156 void tList<T>::add(T* entity)
     158inline void tList<T>::add(T* entity)
    157159{
    158160  if( entity == NULL) return;
     
    171173
    172174template<class T>
    173 void tList<T>::remove(T* entity)
     175inline void tList<T>::remove(T* entity)
    174176{
    175177  if( entity == NULL) return;
  • orxonox/trunk/src/orxonox.cc

    r3660 r3661  
    346346
    347347
    348 #define LIST_MAX 10000
     348#define LIST_MAX 1000
    349349#define VECTOR_MAX 1000000
    350350#define ITERATIONS 10000
     
    635635          printf(" Generate rot matrix: q->matrix(m)\t%11.2f\n", mi);
    636636        }
     637      if( type == 3 || type == -1)
     638        {
     639          /* list tests*/
     640          printf("\nList operations tests: \t\t\t\t\t%i\n", LIST_MAX);
     641          tList<char>* list = new tList<char>();
     642          char* name;
     643
     644          printf(" Adding[1..10] elements to list, found:\n");
     645          list->add("1");
     646          list->add("2");
     647          list->add("3");
     648          list->add("4");
     649          list->add("5");
     650          list->add("6");
     651          list->add("7");
     652          list->add("8");
     653          list->add("9");
     654          list->add("10");
     655
     656          /*give list out */
     657          tIterator<char>* iterator = list->getIterator();
     658          name = iterator->nextElement();
     659          printf("  List Elements: \t\t");
     660          while( name != NULL)
     661            {
     662              printf("%s,", name);
     663              name = iterator->nextElement();
     664            }
     665          delete iterator;
     666          printf("\n");
     667
     668
     669          /*removing some elements from the list*/
     670          printf(" Removing elements [2,3,6,8,10], adding [11] now found:\n");
     671          list->remove("2");
     672          list->remove("3");
     673          list->remove("6");
     674          list->remove("8");
     675          list->remove("10");
     676          list->add("11");
     677          /*give list out */
     678          iterator = list->getIterator();
     679          name = iterator->nextElement();
     680          printf("  List Elements: \t\t");
     681          while( name != NULL)
     682            {
     683              printf("%s,", name);
     684              name = iterator->nextElement();
     685            }
     686          delete iterator;
     687          printf("\n");
     688         
     689          delete list;
     690          printf("\nChecking list performance:\t\t\t\t%i\n", LIST_MAX);
     691
     692          tList<int>* plist = new tList<int>();
     693          unsigned long mittel, ini, end;
     694          float mi;
     695          int i = 0;
     696          mittel = 0;
     697          for(i = 0; i < LIST_MAX; ++i)
     698            {
     699              rdtscl(ini);
     700             
     701              plist->add(&i);
     702             
     703              rdtscl(end);
     704              mittel += (end - ini - dt);
     705            }
     706          mi = mittel / (float)LIST_MAX;
     707          printf(" Adding reference to list:\t\t%11.2f\n", mi);
     708
     709          mittel = 0;
     710          for(i = 0; i < LIST_MAX; ++i)
     711            {
     712              rdtscl(ini);
     713             
     714              plist->remove(&i);
     715             
     716              rdtscl(end);
     717              mittel += (end - ini - dt);
     718            }
     719          mi = mittel / (float)LIST_MAX;
     720          printf(" Removing 1st reference from list:\t%11.2f\n", mi);
     721         
     722         
     723
     724        }
    637725    }
    638726}
  • orxonox/trunk/src/simple_animation.cc

    r3573 r3661  
    111111SimpleAnimation::~SimpleAnimation ()
    112112{
    113   KeyFrame* frame = this->frames->enumerate();
     113  tIterator<KeyFrame>* iterator = this->frames->getIterator();
     114  KeyFrame* frame = iterator->nextElement();
    114115  while( frame != NULL)
    115116    {
    116117      delete frame;
    117       frame = frames->nextElement();
     118      frame = iterator->nextElement();
    118119    }
     120  delete iterator;
    119121  delete this->frames;
    120122}
     
    163165void SimpleAnimation::reset()
    164166{
    165   KeyFrame* frame = this->frames->enumerate();
     167  tIterator<KeyFrame>* iterator = this->frames->getIterator();
     168  KeyFrame* frame = iterator->nextElement();
    166169  while( frame != NULL)
    167170    {
    168171      delete frame;
    169       frame = frames->nextElement();
     172      frame = iterator->nextElement();
    170173    }
     174  delete iterator;
    171175  delete this->frames;
    172176
  • orxonox/trunk/src/track_manager.cc

    r3608 r3661  
    7070  if ((!this->isJoined &&this->childCount > 0) || (this->isJoined && this->mainJoin))
    7171    {
    72       TrackElement* enumElem = children->enumerate();
     72      tIterator<TrackElement>* iterator = this->children->getIterator();
     73      TrackElement* enumElem = iterator->nextElement();
    7374      while (enumElem)
    7475        {
    7576          delete enumElem;
    76           enumElem = children->nextElement();
     77          enumElem = iterator->nextElement();
    7778        }
     79      delete iterator;
    7880      delete this->children;
    7981    }
     
    9597  if (this->childCount > 0)
    9698    {
    97       TrackElement* enumElem = this->children->enumerate();
     99      tIterator<TrackElement>* iterator = this->children->getIterator();
     100      TrackElement* enumElem = iterator->nextElement();
    98101      TrackElement* tmpElem;
    99102      while (enumElem)
     
    101104          if ((tmpElem = enumElem->findByID(trackID)))
    102105            return tmpElem;
    103           enumElem = this->children->nextElement();
     106          enumElem = iterator->nextElement();
    104107        }
     108      delete iterator;
    105109    }
    106110  else
     
    120124  else
    121125    {
    122       TrackElement* enumElem = this->children->enumerate();
     126      tIterator<TrackElement>* iterator = this->children->getIterator();
     127      TrackElement* enumElem = iterator->nextElement();
    123128      while (enumElem)
    124129        {
    125130          if(!enumElem->backLoopCheck(trackElem))
    126131            return false;
    127           enumElem = this->children->nextElement();
     132          enumElem = iterator->nextElement();
    128133        }
     134      delete iterator;
    129135     
    130136      return true;
Note: See TracChangeset for help on using the changeset viewer.