The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: ecube on November 17, 2006, 06:23:25 PM

Title: printf speed tests
Post by: ecube on November 17, 2006, 06:23:25 PM
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]
Title: Re: printf speed tests
Post by: zooba on November 17, 2006, 11:24:53 PM
wsprintf 593
printf 1143
xPrintf 6138
gPrintf 6070
Format 3884 (from ASM Runtime 0.300 (http://web.aanet.com.au/zooba/projects.html))
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
Title: Re: printf speed tests
Post by: ecube on November 17, 2006, 11:56:19 PM
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.
Title: Re: printf speed tests
Post by: zooba on November 19, 2006, 04:03:21 AM
I just posted some benchmarking of the heap allocation functions here (http://www.masm32.com/board/index.php?topic=6190.new) 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
Title: Re: printf speed tests
Post by: Vortex on November 19, 2006, 07:29:24 AM
E^cube,

Nice work :U