Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: rickman Newsgroups: comp.arch.embedded Subject: Re: Slightly OT: speed of operation on a PC Date: Wed, 05 Aug 2015 20:19:25 -0400 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <006ed9bc-bbaa-4b4f-b532-4c2508c36efe@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 6 Aug 2015 00:17:52 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="c3dfb0c42f2565cb68aa569be809f91b"; logging-data="24824"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sJW5yCxYVUfxojaYR3jUl" User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <006ed9bc-bbaa-4b4f-b532-4c2508c36efe@googlegroups.com> Cancel-Lock: sha1:jAal2S/UZec7dCEEpw4PINuntpM= Xref: csiph.com comp.arch.embedded:21682 On 8/5/2015 1:31 PM, edward.ming.lee@gmail.com wrote: > On Tuesday, August 4, 2015 at 10:59:08 AM UTC-7, Tim Wescott wrote: >> Which do you think is quicker on a PC, with the latest gnu compiler: >> >> double a = something; >> double b = something else; >> >> if (a >= 0.0 && b < 0.0) >> >>>> or << >> >> if (a * b <= 0) >> >> Thank you for your time. > > I just wrote a test program. The first statement is 10% faster than the second. You can argue all you want, but nothing beat benchmarking. What code is generated? Seems like 10% is close enough that "faster" may change with different hardware and tools. -- Rick