Archived Forum Post

Index of archived forum posts

Question:

why your CkString so slow?

Dec 24 '12 at 08:59

C++ project, why CkString so slow?

Example:

DWORD bingotestBe = GetTickCount ();

for (int i = 0; i <100000; i + +)
{
CkString cks;
cks.setStringU (_T ("Hello world"));
cks.appendU (_T ("!!!"));
cks.clear ();
}
DWORD bingotestEn = GetTickCount () - bingotestBe;
cout << "ck:" << bingotestEn << endl;

bingotestBe = GetTickCount ();
for (int i = 0; i <100000; i + +)
{
wstring str;
str = _T ("Hello world");
str + = _T ("!!!");
str.clear ();
}
bingotestEn = GetTickCount () - bingotestBe;
cout << "std:" << bingotestEn << endl;
Results:

ck: 10344

std: 94

How to improve the speed of your product?


Answer

The slowness is due to the CkString constructor. If the object is moved outside the loop, then performance should improve significantly.

In any case, Chilkat has addressed this problem internally and can provide a new build (v4.7.1 pre-release) that greatly improves the performance, even if the CkString object is kept inside the loop. Please let me know what version of VC++ you use, or if using a non-Windows OS, which operating system (and if it's 32-bit or 64-bit).