Main BLOGGER
Google
WWW THIS BLOG
Wednesday, July 05, 2006
 
ACE_String performance

From Ajith

 

String allocation/deallocation is a primary cause of heap fragmentation and poor performance.

 

There are three things that we can do to speed up string usage.

 

1.

const SymString fname="my func";

should be .. static const SymChar fname[]=SymText("my func");

 

SymString will allocate memory for "my func" and copy it every time the function is entered.

 

2.

SymString myString = "x";

if (myString == "x") do something;

should be .. if (ACE_OS::strcmp(myString, "x") == 0) do something;

 

SymString doesn't implement the operator== for a char *. Instead it will copy "x" into another SymString, do the compare and then free it.

 

3.

SymString myGetFn()

{

    return m_value;

}

 

should be

const SymString & myGetFn() const

{

    return m_value;

}

 

Always return a const reference in a Get fn. It is also a good idea to declare the Get fn as const.

 


 
On performance: socket programming

http://www-128.ibm.com/developerworks/linux/library/l-hisock.html?ca=dgr-lnxw07BoostSocket

 

 

  • Minimize packet transmit latency.
  • Minimize system call overhead.
  • Adjust TCP windows for the Bandwidth Delay Product.
  • Dynamically tune the GNU/Linux TCP/IP stack.

 



Powered by Blogger

Google
WWW THIS BLOG