Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Jun 2000 20:17:48 -0400 (EDT)
From:      Steve Quirk <squirk@home.com>
To:        "Daniel C. Sobral" <dcs@newsguy.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Optimization
Message-ID:  <Pine.BSF.4.21.0006052012420.31225-100000@cc677580-a.sumt1.nj.home.com>
In-Reply-To: <200006052347.IAA00583@daniel.sobral>

next in thread | previous in thread | raw e-mail | index | archive | help
"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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0006052012420.31225-100000>