|
-
November 17th, 2010, 03:32 AM
#1
GetTextExtentPoint32 is really slow on Windows Mobile, any alternative?
I wrote a simple demo below to discover why GetTextExtentPoint32 is slow,
Code:
void CSmartGetTextExtentDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CDC* dc = GetDC();
HDC hdc = dc->GetSafeHdc();
printf("begin GetTextExtent test\n");
string text1("Initialize the shell activate info structure");
SIZE size;
UINT64 startTime = getTicks();
::GetTextExtentPoint32(hdc, (LPCTSTR)(text1.c_str()), text1.size(), &size);
UINT64 endTime = getTicks();
UINT64 duration = endTime - startTime;
printf("str1: %d ms\n", duration);
string text2("Initialize the shell activate info structure");
startTime = getTicks();
::GetTextExtentPoint32(hdc, (LPCTSTR)(text2.c_str()), text2.size(), &size);
endTime = getTicks();
duration = endTime - startTime;
printf("str2: %d ms\n", duration);
printf("end GetTextExtent test\n\n");
ReleaseDC(dc);
}
The result was really confusing.
In first run, the 2 resulting duration were all around 300~400ms, even if they were same strings.
Then I clicked button to trigger test again, the time cost was obviously decreased to almost 0ms.
I restarted demo, the result was 0~1ms every time.
Then I reboot my device (not simulator), ran test twice or more like above, the first run was still slow, and became faster after that.
I guessed the system cached something I didn't figure out, but the confusing thing was that why it was slow even if they're 2 same strings in first run.
Any idea about this weird thing and any alternative?
thx in advance.
Last edited by LifeIsSuffering; November 17th, 2010 at 03:34 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|