Optimizing Java using D
Xinok via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 3 12:53:44 PDT 2014
On Thursday, 3 July 2014 at 07:29:42 UTC, Wanderer wrote:
> Nobody, never, measures sort algorithms by amount of swaps.
Maybe not in swaps, but I have seen sorting algorithms measured
similarly using reads and writes. As others have stated, it can
be a useful metric if you're sorting a range of structs.
Another example, it's possible to implement an in-place merge
sort. It performs just slightly more comparisons than a regular
merge sort. However, it's still slower because it requires
significantly more reads and writes.
It's not the only metric though, and other things are difficult
to measure. A bottom-up heapsort performs fewer comparisons than
quicksort, but quicksort is still faster. That's because
quicksort runs over the range sequentially which makes it "cache
friendly" whereas heapsort relies heavily on random access.
Metrics aside, nothing beats a good ol' benchmark.
More information about the Digitalmars-d
mailing list