[darcs-users] darcs patch: Remove premature optimization.

Jason Dagit dagit at codersbase.com
Sat May 23 08:18:17 UTC 2009


On Fri, May 22, 2009 at 9:58 PM, Trent W.Buck <trentbuck at gmail.com> wrote:
> Out of interest, I replaced the horribly confusing code with an
> obviously inefficient -- but readable -- version, and timed
> difference.  The sum of three runs of "darcs show authors" on the
> Darcs repo and the darcs-wiki repo, on a fast system, is:
>
>  real   user   sys
>  1.090s 0.670s 0.140s          -- without this patch
>  3.394s 3.080s 0.160s          -- with this patch
>
> So readability will quintuple the CPU time, though the operation's
> total time is negligible.  Is it worth applying this patch?

My preference would be to add a comment saying that the optimized code
is just equivalent to your version.  That way people reading the
source have a better clue what it is doing, but the people using darcs
don't have to wait any longer than they already wait.  Do you think
that would be reasonable?

On a side note, premature optimizations are bad, but I doubt I would
consider this such.

Jason


More information about the darcs-users mailing list