[ROOT] TMap performance

From: Ivana Hrivnacova (Ivana.Hrivnacova@cern.ch)
Date: Tue Oct 07 2003 - 11:15:28 MEST


 Hello,

 The change of std::map to TMap in our code has
 caused a perfomance penalty by factor 4 for our test.
 That's why I'd like to understand if 
 TMap was used in an optimal way.
 
 The description what has been done is below,
 the full class is in the attachement.
 (It would take more time to extract the problem into
 a simpler example and to reproduce the problem in it.)
 
 Thank you.
 
 Versions: Root 3.05.07, gcc 3.1
 
 Ivana Hrivnacova  
 
 -----
 
 The map is defined as:
 STL:
 typedef map<AliMpIntPair, AliMpConnection*> ConnectionMap_t;
 typedef ConnectionMap_t::const_iterator   ConnectionMapCIterator;
 ConnectionMap_t fConnections; //! Map (ix,iy) of connections

 Root:
 typedef TMap      ConnectionMap_t;
 typedef TMapIter  ConnectionMapCIterator;
 ConnectionMap_t fConnections; //! Map (ix,iy) of connections
 
 The map is filled by
 (it is filled only once in the program):
 const AliMpIntPair& localIndices; 
 AliMpConnection* connection;
 fConnections[localIndices]=connection;  // STL
 fConnections.Add(new AliMpIntPair(localIndices), connection); //Root

 The search by a key is performed as:
#ifdef WITH_STL
  ConnectionMapCIterator i = fConnections.find(localIndices);
  if (i != fConnections.end())
    return i->second;
  else 
    return 0;
#endif

#ifdef WITH_ROOT
  AliMpIntPair* key;
  ConnectionMapCIterator i(&fConnections);
  while ((key = (AliMpIntPair*)i.Next())) {
    if (*key == localIndices) 
      return (AliMpConnection*)fConnections.GetValue(key);
  }  
  return 0;
#endif

   The search by various characteristics of AliMpConnection
   is performed as:
#ifdef WITH_STL
 for (ConnectionMapCIterator i = fConnections.begin(); i!=fConnections.end();++i)
   if (i->second->GetGassiNum()==gassiNum) return i->second;
#endif

#ifdef WITH_ROOT
  TObject* key;
  AliMpConnection* connection;
  ConnectionMapCIterator i(&fConnections);
  while ((key = i.Next())) {
    connection = (AliMpConnection*)fConnections.GetValue(key);
    if (connection->GetGassiNum()==gassiNum) return connection;
  }  
#endif

-- 
==============================================================
e-mail:  Ivana.Hrivnacova@cern.ch
address: Institut Physique Nucleaire, 91406 Orsay, France
phone:   (33) 01 69 15 65 94
==============================================================







This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET