[fpc-devel] Is calling the Windows Unicode APIs really faster than the ANSI API's?

Sergei Gorelkin sergei_gorelkin at mail.ru
Fri Sep 26 16:04:45 CEST 2008


Graeme Geldenhuys wrote:

> Has anybody else got sample test code that clearly shows the claimed
> "significant speed gain" in using UTF-16 for Windows API's?  If so,
> could you please post the code and your comparative results (timing
> values).  I think most people perception was that ANSI API's will be
> slower, but never really bothered to actually proof that it was.

Such testing is pretty much useless, because the speed of any real 
program depends on what this program is doing.
However, since I've done intensive benchmarking while developing the XML 
parser, here are some results:

Parsing an XML file with 1 million chars, 25000 elements and 18000 text 
nodes is about 10% faster for UTF-16 than for UTF-8 (despite the byte 
count is twice bigger).
At the same time, the parsing itself takes only about 30% of total time. 
The rest is spent in the memory manager. The memory manager usage 
pattern also matters: it works faster when you only allocate memory than 
when you allocate, free, then allocate again.

The speed of string conversion itself might be unnoticeable on modern 
CPUs, but remember that each conversion is at least two memory manager 
calls, plus a guarding exception frame.


Regards,
Sergei



More information about the fpc-devel mailing list