News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

printf speed tests

Started by ecube, November 17, 2006, 06:23:25 PM

Previous topic - Next topic

ecube

Well I found godlikes string library here yesterday and thought i'd speed test his gprintf. It's not a complete clone of printf or wsprintf but supports some of the format-control specifications. The package attached includes

glib(godlikes string library)
xmlib (my attempt to optimize glib alittle by replacing his strcmp function with lingos, sometimes its a lot faster on the same string than the glib is, sometimes slower, thought that was odd)
wxprintf(my procedure!! only supports %s but I wanted to play to :)

on my machine just for %s the results were
wsprintf 682
printf 1470
xPrintf 1047
gPrintf 997
wxprintf 24 (yes 24  :U)

[attachment deleted by admin]

zooba

#1
wsprintf 593
printf 1143
xPrintf 6138
gPrintf 6070
Format 3884 (from ASM Runtime 0.300)
wxprintf 46

I have no idea why xPrintf and gPrintf were so slow. Perhaps the optimisations aren't valid for a P3M? (I tested a few times and the numbers didn't change much)

Format also automatically allocates a buffer on the heap (in chunks of 128bytes IIRC) and the timing includes freeing that buffer after each call. It's also a debug version, though I don't think that'll make much difference to the performance. It's designed to 'just work' and work nicely rather than be super fast.

I quite like wxprintf - you could probably market it as an 'advanced string concatenation' function rather than a 'simplified printf' function - sounds more impressive that way :wink

Cheers,

Zooba :U

Edit: Fixed link

ecube

Thanks zooba, yeah i'm working on adding more features to wxprintf so it can be a more fair comparison. Also my wxreplace procedures are almost done, one uses an external buffer, other doesn't, both really fast :) am trying to learn from gurus like lingos code, hes won almost every speed contest on this forum, and the fact he mentioned he loves asm and sees it as an art, I have a lot of respect for him.

zooba

I just posted some benchmarking of the heap allocation functions here which are used extensively throughout Format. Using a regular heap it now runs in 2574. The first timing may have been better than it should've been, since the format marker needed changing (% instead of just %s) and I may have forgotten it. There's probably a extra string copies I could get rid of too, though I think that it's quick enough given the power involved :bg

I still get huge numbers for x/gPrintf which I can't figure out from reading the code. They both look fine to me... who knows

Cheers,

Zooba :U

Vortex