Difference between revisions of "Profiling"

From OTBWiki
Jump to: navigation, search
Line 3: Line 3:
 
===Method GetSize()===
 
===Method GetSize()===
  
**Avoid:
+
*Avoid:
 
''for (int i=0;i<v.GetSize();++i)  
 
''for (int i=0;i<v.GetSize();++i)  
 
{
 
{
 
}''
 
}''
  
**Prefer:
+
*Prefer:
 
''const unsigned int size = v.GetSize();
 
''const unsigned int size = v.GetSize();
 
for (int i=0;i<size;++i)  
 
for (int i=0;i<size;++i)  
 
{
 
{
 
}''
 
}''

Revision as of 10:05, 26 May 2010

This page compiles some profiling conclusions and tips:

Method GetSize()

  • Avoid:

for (int i=0;i<v.GetSize();++i) { }

  • Prefer:

const unsigned int size = v.GetSize(); for (int i=0;i<size;++i) { }