[fpc-devel] Patch to speed up Uppercase/Lowercase functions

Daniël Mantione daniel at deadlock.et.tudelft.nl
Sat Jun 11 16:41:53 CEST 2005



Op Sat, 11 Jun 2005, schreef Michael Van Canneyt:

>
>
> On Sat, 11 Jun 2005, Joost van der Sluis wrote:
>
> > If we're gonna hold a discussion like this for every optimilisation, it
> > isn't worth the effort imho. But now we're busy with it:
> >
> > > Well. Discussion is nice, but what does the real world show ?
> >
> > > To compare, I made 6 versions of Lowercase:
> > > 1 - Sysutils
> > > 2 - Sysutils with Joost's improvement.
> > > 3 - Sysutils with Joost's improvement, but forward loop.
> > > 4 - Using PChar.
> > > 5 - Using PChar with lookup table and if check
> > > 5 - Using Pchar with lookup table and no check.
> >
> > You shoudn't use the sysutils's version. It's better to copy the source
> > from sysutils to the testprogram.
> >
> > I've added that (lowercase1) and i've added Daniel's asm-procedure...
>
> Timing for Daniel's procedure doesn't count, it's shortstrings.
> They are limited to 256 characters, obviously this will execute faster;

It is also a bad test, it should be converted to ansistring for proper
comparison. The string s is declared in $H+ state, so the
compiler has to convert an ansistring to shortstring, then do the
lowercase and then convert the result back to ansistring to be able to
assign to t. The fact that it is still faster shows what speed gains
you can still get anno 2005.

> The ansistring S used is 2400 characters (so a factor 10 longer).

No, Joost's test uses a much shorter string (which is also the most likely
reason the benchmarks give contradictory results).

Daniël





More information about the fpc-devel mailing list