Saturday, September 09, 2006

Performance tune

1. dead link(maybe)
http://www.intel.com/software/products/college/vtune/getstart/tutorial/index.htm

2. Reference in book
代码优化:有效使用内存 第1章 1.6

3. A Simple Tour
http://hpcjl.ustc.edu.cn/doc/34.ppt

4.vtune 8.1 system requirement
http://www.intel.com/cd/software/products/asmo-na/eng/vtune/vlin/239147.htm

5. Improving Program Performance
http://docs.sun.com/source/819-3690/Perf.html

6.

How I Got 15x Improvement Without Really Trying: A Case Study in Program Optimization

http://developers.sun.com/sunstudio/articles/Feo/feo_content.html

Tuesday, September 05, 2006

Cases of unit test

Case 1:
1. Subject: Design a method 'filterStringList' to erase those strings whose length is not less than 4 out from a list. The prototype of the method is declared like this:
typedef list StringList;
typedef unsigned int StringLength;
void filterStringList(StringList &list, const StringLength maxLength);
2. Unit test design:
void test_filterStringList()
{
StringList strList;
strList.push_back("1");
strList.push_back("22");
strList.push_back("333");
strList.push_back("4444");
strList.push_back("55555");
strList.push_back("666666");

filterString(strList, 4);
CPPUNIT_ASSERT(3 == strList.count());
CPPUNIT_ASSERT("1" == strList.[0]);
CPPUNIT_ASSERT("22" == strList.[1]);
CPPUNIT_ASSERT("33" == strList.[2]);
}

3. My first impletement (fail to run unit test)
void filterStringList(StringList &list, const StringLength maxLength)
{
StringList::iterator it = list.begin();
for(; it != list.end(); ++i)
{
if((*it).length() >= maxLength)
it = list.erase(it);
}
}

It can't passed the test.

4. The final impletement

void filterStringList(StringList &list, const StringLength maxLength)
{
StringList::iterator it = list.begin();
while(it != list.end())
{
if((*it).length() >= maxLength)
it = list.erase(it);
else
++it;
}
}