9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Sam <sah@softcardsystems.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] env walk
Date: Wed,  9 May 2001 13:39:35 -0400	[thread overview]
Message-ID: <01050913393503.04828@softnet> (raw)
In-Reply-To: <01050913344601.04828@softnet>

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 <u.h>
> > #include <libc.h>
> >
> > 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."



  reply	other threads:[~2001-05-09 17:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-09 16:58 presotto
2001-05-09 17:34 ` Sam
2001-05-09 17:39   ` Sam [this message]
2001-05-10  8:33 ` Peter Schay
  -- strict thread matches above, loose matches on Subject: below --
2001-05-10 14:48 rog
2001-05-10 14:41 presotto
2001-05-10 13:49 rob pike
2001-05-10 13:39 rog
2001-05-10 13:04 presotto
2001-05-10 12:58 presotto
2001-05-09 13:23 presotto
2001-05-09 15:45 ` Peter Schay
2001-05-09 11:54 Peter Schay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01050913393503.04828@softnet \
    --to=sah@softcardsystems.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).