Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!transfer!lectroid!jjmhome!smds!rh From: rh@smds.UUCP (Richard Harter) Newsgroups: comp.lang.c Subject: Re: Some optimization results Summary: Better timings Message-ID: <445@smds.UUCP> Date: 4 May 91 22:55:58 GMT References: <444@smds.UUCP> Organization: SMDS Inc., Concord, MA Lines: 26 This is a followup. The timings referred to were done in situ, i.e. the routine being tested was executed as part of the execution of a large program running a fixed test suite. For the purposes of timing this is not entirely happy because of the high variance of gprof timings. To get better times, I set up a test bed program to time the loop itself. All variables were register variables with the arrays and pointers being ints. Here are the loop times: Statement Unroll=1 Unroll=8 if (*ia++ != *ib++) break; .58 ms .48 ms check += (*ia++ == *ib++); .43 ms .33 ms check |= (*ia++ ^ *ib++); .32 ms .20 ms These times are fairly repeatable. Note that the time reduction due to unrolling loops is constant. This implies that loop unrolling only provides signifigant improvements in relative times if the loop is very tight. Also not that loop unrolling past 8 times offers very little advantage -- with a unroll factor of 8 you have already removed 7/8 of the loop tests. -- Richard Harter, Software Maintenance and Development Systems, Inc. Net address: jjmhome!smds!rh Phone: 508-369-7398 US Mail: SMDS Inc., PO Box 555, Concord MA 01742 This sentence no verb. This sentence short. This signature done.