Execution time bottleneck: How to speed up execution?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu Feb 14 22:32:53 AEST 1991


In article <2934 at charon.cwi.nl> dik at cwi.nl (Dik T. Winter) writes:
> This is ludicrious.

Look, Richard's original took 15.6 seconds on a Sun, 14.2 with cc -O4,
all with n = 1000. Mine took 15.0 seconds, 13.8 with cc -O4. That's a 4%
speedup.

On a Convex, Richard's took 3.91 without optimization, 3.03 with. Mine
took 3.56 without, 2.72 with. That's a 10% speedup.

With a fast exp I have lying around, the speedups become 33% and 52%
respectively. (This exp uses four tables of size 65536 and does table
lookup.)

I made one mistake in my transformations: j should have been initialized
to n - 1, not n, in the main loop. (Richard should have done the same
thing, but he was properly defensive and used <= rather than !=. Oops.)
That bug took me one minute to find. Writing the article in the first
place took about fifteen minutes, most of that for explaining the
transformations rather than doing them.

Dik, take a step back and look at your contribution to this discussion.
Who's trying to be more helpful, you or me? I'm saying ``Here are some
optimizations. I hope you find them useful.'' You're saying ``Don't
optimize your code. Even though you care about its speed enough to spend
a few minutes asking the net for help, surely you don't think it's worth
a few minutes of programming time to make it run noticeably faster.''

Why would anyone want to take that advice?

---Dan



More information about the Comp.lang.c mailing list