home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!destroyer!ubc-cs!van-bc!tram!jeffrey
- From: jeffrey@squid.tram.com (Jeffrey L Bromberger)
- Subject: Re: Optimizing code for tests
- Organization: Tramway Unix Systems
- Date: Wed, 12 Aug 1992 15:31:58 GMT
- Message-ID: <1992Aug12.153158.13990@squid.tram.com>
- Keywords: CC GCC f77
- References: <1992Aug11.162502.8848@squid.tram.com>
- Lines: 39
-
- In article <1992Aug11.162502.8848@squid.tram.com> I wrote:
-
- >with the random number generator; it may be fast, but 50% of my time
- >is spent there...
-
- So far, all I have gotten in reply is "50%?!?!?" I have gotten
- comments like:
-
- Don't use rand() I already don't
- Use *this* one I've got a nice one, thanks
- It should be small So it is...
-
- Maybe I'll have to explain. The generator is not at fault. The
- problem is that it gets called nearly 2^15 times for each simulated
- "event". Make that now 30,000 events repeated over 30,000 simulated
- years (for a small run) and you're talking about (Carl Sagan Mode ON)
- Millyuns and Millyuns :-)
- of calls to the generator. Prof tells me it's the fastest of all
- routines, clocking in at 0.04msec per run. It still adds up.
-
- One suggestion I'd like to know more about, but have no idea where to
- follow it up is "make the generator in-line code". Any pointers on
- this idea? Does it just involve moving a copy of the generator code
- everywhere it's called (as opposed to having it's own function)?
-
- >What I am trying to optimize are my comparisons.
- >So, is it really worth my while to worry about which path is fastest?
-
- Honestly, everyone (except for one passing remark) seems to be
- avoiding the question I posed. Is the compiler really doing anything
- different speed-wise if the test passes or fails? Should I just give
- up on this point? Stick to it just for the sake of coherent style?
-
- Thanks!
-
- j
- --
- Jeffrey L. Bromberger ------- System Manager ------- Tramway Unix Systems
- jeffrey@squid.tram.com Anywhere!{van-bc,limbic,icus}!tram!jeffrey
-