[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: CString to CStringA conversion and other questions :)

From: Oto BREZINA <otik_at_printflow.eu>
Date: Tue, 21 Aug 2012 16:07:18 +0200

On 2012-08-20 21:03, Stefan Küng wrote:
> On 20.08.2012 20:40, Oto BREZINA wrote:
>
>> I'm NOT about to rewrite CheckUnicodeType, just was wonder when I read
>> it if *ptr++ is faster.
>> In fact I was little bit about - I wrote simple UTF8 validator some time
>> ago, and seeing your implementation with lot of nested ifs, ++ etc, I
>> was wondering what are cons and pros to compare with my - more state
>> based implementation.
>> Everything stopped on Performance Analysis tool.
>>
>> In CheckUnicodeType you get thru array twice just to verify if it is UTF8.
>> And it can be enhanced to UTF16BE/LE detection - statisticaly based, so
>> not 100% accurate, but it would cost some processing. For now you need
>> BOM for UTF16s.
>>
>>
> Looks like a good idea.
> If you want to do some profiling:
> have a look at the src\utils\profiling.h file. It's a simple time
> measuring tool that helps finding out if a change has an effect on
> performance or not.
>
> Simply add
> PROFILE_BLOCK;
> somewhere inside a function, then make a release build, run the app and
> that function, exit the app. A file will be written to the same folder
> as the exe is where all the time measurements are shown.
>
> to profile a simple line, use
> PROFILE_LINE(call_function());
>
> But I prefer the
> PROFILE_BLOCK;
>
> in case you need to only profile part of a function, create a 'block'
> using brackets:
>
> function(...)
> {
> ...
> ...
> {
> PROFILE_BLOCK;
> // code to profile
> ...
> }
> }
Thanx for this hint, I was trying to make VS Analyses working but not
success yet, this one is great... so I give up with VS.
Only backside is that Load and Save works with files, and my computer is
used all the time with lot of scheduling, so measuring wall time is not
most informative for algo efficiency checking.

I'll have closer look on this tool later.

Result:
*ptr++ vs ptr[] is case to case even it runs on simple char*

for (int nDword = 0; nDword<nDwords; nDword++)
{
p32[nDword] = DwordSwapBytes(p32[nDword]);
}

vs. something like
for (int nDword = nDwords; nDword; --nDword)
{
*p32++ = DwordSwapBytes(*p32);
}
was faster with about 3:4 time units on 100MB file. Other parts was +/-
equal or slower.

Utf8 validity check is double speed by using bit test instead of byte.
Not sure about *ptr++ vs ptr[].

>
> Stefan
>

-- 
Oto ot(ik) BREZINA - 오토
------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2999905
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2012-08-21 16:07:34 CEST

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.