From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="iso-8859-1" From: Sam To: 9fans@cse.psu.edu Subject: Re: [9fans] env walk References: <20010509165901.CD181199E7@mail.cse.psu.edu> <01050913344601.04828@softnet> In-Reply-To: <01050913344601.04828@softnet> MIME-Version: 1.0 Message-Id: <01050913393503.04828@softnet> Content-Transfer-Encoding: 8bit Date: Wed, 9 May 2001 13:39:35 -0400 Topicbox-Message-UUID: 9c82a230-eac9-11e9-9e20-41e7f4b1d025 ugh...'scuse the flub. On Wednesday 09 May 2001 13:34, you wrote: > schweet > > John had looked at it on Monday and it said Showers Sat-Mon...guess the > storm got pushed back. > > ... ok, I'm getting a little excited now. > > :) > > On Wednesday 09 May 2001 12:58, you wrote: > > The n**2 comes from the ls M* walking each entry in the environment > > with envwalk walking from the first to that entry every time. All the > > time is spent in the devdir+convM2D in procgen. The > > > > for(e = eg->entries; e && s; e = e->link) > > s--; > > > > is pretty much fleeting even for 1000 entries. Otherwise the algorithm > > for your example would be n**3. > > > > for example: > > > > #include > > #include > > > > struct X > > { > > struct X *next; > > }; > > > > struct X x[1000]; > > > > void > > main(void) > > { > > struct X *p; > > int i, j; > > > > for(i = 0; i < nelem(x)-1; i++) > > x[i].next = &x[i+1]; > > > > for(i = 0; i < nelem(x); i++) > > for(j = 0, p = x; j < i && p != nil; p = p->next, j++) > > ; > > > > } > > > > takes .01 seconds on my crufty old machine. > > The advantage to your loop is that you take all the useless stuff > > that devdir does out of the inner loop, not too mention the call > > itself. -- Sam Hopkins ------------------------------------------------ QOTD: "Design top down, implement bottom up."