In article <[EMAIL PROTECTED]> you write:
> ok, but it gets more interesting as take into account moores law that
> reduces the effectiveness of optmisation by halving the improvement of the
> optimization every year [...]

This depends. If you're just doing an optimisation that changes one O(N)
algorithm for another, then you're probably better off with the most clear
version and wait for Moore's Law to help. Cycle-pinching optimisation
doesn't really gain much anyway.

[Mind you, I suspect that index and the equivalent regexen may have
different O() scores. Discuss.]

However, the problem is with programmers that don't really understand
algorithms and implement something the "obvious" way, e.g. O(N^2) instead of
O(NlogN) then this is not going to help when you attempt to scale your
website or whatever to a million users instead of a test set of five.

Of course, when the offending O(N^2) is found by the BPFH and the original
coder LARTed, then the replacement O(NlogN) code should still indicate the
API, be well commented and document where the algorithm came from (Mastering
Algorithms with Perl / Knuth / wherever.)

Of course, for small N, crude and simple O(N^2) algorithms can be faster
than fancy ones, but for many cases, N is going to be directly proportional
to your expected profit ;)

Reply via email to