Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!usc!apple!portal!cup.portal.com!ts From: ts@cup.portal.com (Tim W Smith) Newsgroups: comp.lang.c Subject: Re: count of bits in a long Message-ID: <35201@cup.portal.com> Date: 24 Oct 90 06:48:43 GMT References: <1990Oct17.074548.15806@agate.berkeley.edu> <788@demott.COM> Organization: The Portal System (TM) Lines: 17 When benchmarking something like this, a good thing to do is to do a back-of-the-envelope estimate of what you expect. For example, the Mac II runs at 16 MHz. Assume a few wait states, and loop overhead, and stuff like that will limit us to 1 "useful" instruction every 8 clocks, so we get 2 "useful" MIPS. The operation x &= x-1 will take three operations. At 2 MIPS, an operation is 1/2 uSec, so we have 1.5 uSec per bit. The loop runs an average of 16 times, so we expect that we can do it in 24 uSec. The measured time was something like 20 uSec, so we pass. If you see numbers in the hundreds of microseconds, you can be almost sure that something is wrong with the program. Tim Smith