Re: Don't be overawed by a C compiler.
- From: "f0dder" <spamtrap@xxxxxxxxxx>
- Date: Thu, 1 Sep 2005 17:23:21 +0000 (UTC)
hutch-- wrote:
> What is the purpose of introducing the STL template sort and the LIBC
> sort when there is no direct comparison with the exact algorithms ?
Both use the quick sort algorithm. Mayhaps a different implementation,
but I thought it was worth testing the speed of what you get from the
standard library.
> Is either the C or assembler source code available for either ? The whole
> purpose of the practice piece was to perform exact comparisons of the
> same algorithm.
The C++ source is available for STL the templates on any platform that
has STL support - for the simple reason that with just about every
C++ platform today, templates have to be available in source form.
They aren't a real joy to read, though.
The libc qsort routine is available in source form if you own a copy
of visual studio, but it's probably a copyright breach to redistribute
it here, so I won't.
Funny thing is that std::sort is 100% generic but still outperforms your
assembly implementation on all tested platforms. It will work for *any*
type that has a less-than operator defined, and for other types (or if
you want to sort on a different criteria), you can supply a binary
predicate yourself. The template nature makes sure it's fast (ie, no
superfluous "call comparefunc", as it will be inlined instead).
> Just as a note, the old C algo is broken in both its original and
> dumped forms. I cannot really vouch for code I did not design myself
> but the reverse order test in the practice piece did not show the
> broken results.
Why post broken code?
.
- References:
- Don't be overawed by a C compiler.
- From: hutch--
- Re: Don't be overawed by a C compiler.
- From: f0dder
- Re: Don't be overawed by a C compiler.
- From: hutch--
- Don't be overawed by a C compiler.
- Prev by Date: Re: Simple program cwitching thru all video-modes craps-out ...
- Next by Date: Re: Don't be overawed by a C compiler.
- Previous by thread: Re: Don't be overawed by a C compiler.
- Next by thread: Re: Don't be overawed by a C compiler.
- Index(es):
Relevant Pages
|