Path: utzoo!utgpu!attcan!uunet!rosevax!news From: news@rosevax.Rosemount.COM (News administrator) Newsgroups: comp.lang.c Subject: Re: Efficient coding considered harmful? Message-ID: <6548@rosevax.Rosemount.COM> Date: 3 Nov 88 17:18:32 GMT References: <3105@hubcap.UUCP> <34112@XAIT.XEROX.COM> <1700@dataio.Data-IO.COM> <8630@smoke.ARPA> <1704@dataio.Data-IO.COM> <119@twwells.uucp> <273@tijc02.UUCP> Reply-To: merlyn@ernie.Rosemount.COM (Brian Westley) Organization: Rosemount Inc., Burnsville, MN Lines: 21 [profile of prime calculation] >%time cumsecs #call ms/call name > 82.7 4.77 _sqrt [in code] > for (i = 2; i <= root(n); i++) [note: root() calls sqrt()] sqrt() shouldn't dominate your profile so much after you take it out of the loop. This isn't fortran; root() is called on every iteration. True, some optimizations are maintenance pessimizations, but most C compilers can't tell when function calls can be optimized out. Thus the call for a "pure function" keyword (a function whose value is the same for the same arguments, with no side effects). > Paul Schmidt Merlyn LeRoy