From owner-freebsd-hackers Mon Jun 5 17:18: 8 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from cc677580-a.sumt1.nj.home.com (cc677580-a.sumt1.nj.home.com [24.3.178.81]) by hub.freebsd.org (Postfix) with ESMTP id DFD5E37BE32 for ; Mon, 5 Jun 2000 17:17:58 -0700 (PDT) (envelope-from squirk@home.com) Received: from localhost (squirk@localhost) by cc677580-a.sumt1.nj.home.com (8.9.3/8.9.3) with ESMTP id UAA36387; Mon, 5 Jun 2000 20:17:48 -0400 (EDT) (envelope-from squirk@home.com) X-Authentication-Warning: cc677580-a.sumt1.nj.home.com: squirk owned process doing -bs Date: Mon, 5 Jun 2000 20:17:48 -0400 (EDT) From: Steve Quirk X-Sender: squirk@cc677580-a.sumt1.nj.home.com To: "Daniel C. Sobral" Cc: hackers@FreeBSD.ORG Subject: Re: Optimization In-Reply-To: <200006052347.IAA00583@daniel.sobral> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "A" is a simple memory fetch and both instructions can operate independantly (the ".x", ".y" are just arbitrary struct offsets, right?). "B" is a fetch and a couple of trips through the ALU. It's splitting hairs, but I would opt for A since the memory cache should help with the slower memory access. Steve On Tue, 6 Jun 2000, Daniel C. Sobral wrote: > Can someone discuss the performance trade-offs of the following two > alternative codes (and maybe suggest alternatives)? > > Problem: I need to retrieve two values from a table. > > Alternative A: > > x = table[i].x; > y = table[i].y; > > Alternative B: > > d = table[i]; > x = d & MASK; > y = d >> SHIFT; > > -- > Daniel C. Sobral (8-DCS) > dcs@newsguy.com > dcs@freebsd.org > capo@there.is.no.bsdconspiracy.net > > To err is human -- to blame it on a computer is even more so. > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message