Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jato!csi!sam
From: sam@csi.jpl.nasa.gov (Sam Sirlin)
Subject: Re: Memory usage under J 5.1 /386 (PC)
Message-ID: <1992Sep1.170534.11574@csi.jpl.nasa.gov>
Originator: sam@kalessin
Keywords: j51pc386,memory
Sender: usenet@csi.jpl.nasa.gov (Network Noise Transfer Service)
Nntp-Posting-Host: kalessin
Organization: Jet Propulsion Laboratory, Pasadena, CA
References:  <695@svcs1.UUCP>
Date: Tue, 1 Sep 1992 17:05:34 GMT
Lines: 66


In article <695@svcs1.UUCP>, slix@svcs1.UUCP (Bill Miller) writes:
|> I did some more experimentation with j51 for 386 pc's, and I have a question
|> about J's memory usage.
|> For example, if I do:
|>    7!:3 '+/ i. 10000' for 'space to execute', it returns something ca. 200K,
         ^
you mean 2 here for "space to execute"?

|> and I think that is a bit much.  I figure since ints are 4 bytes each on a
|> 386, then that expression should take realistically no more than 80K (twice
|> what i. 10000 should take, which is 4*10,000.  Perhaps there would be some
|> extra temp space needed to compute the +/, but frankly I can't see why
|> it would take that much.
|> Comments?

Well here are some numbers from a sun sparc:
   7!:2 '10000$1' NB. boolean space
10184
   7!:2 '10000$2' NB. integer
40180
   7!:2 '10000$2.1' NB. real
80204
   7!:2 '10000$_1^0.5' NB. complex
160508
   7!:2 'i.10000'
80276
Looks like the output of i. is real!

   7!:2 '+/ 10000$1'
10476
   7!:2 '+/ 10000$2'
160496
   7!:2 '+/ 10000$2.1'
160480
   7 !:2 '+/10000$_1^0.5'
320780
Again not much distinction between integer and real. But it looks like
+/ takes about a factor of 2 in space...

   7!:2 '+/ i. 10000'
200600
   7!:2 '+/ 3*i. 10000' NB. integer
320740
   7!:2 '+/ o. i. 10000' NB. real
360704
   7!:2 '+/ (_1^0.5)*i. 10000' NB. complex
601120

So +/ i. takes about 1.25 times as long as summation over reals. But
with an operation in between seems to take just the expected factor of
2 (for the copy). 

So what about
   7!:2 '+/a=. i.10000'
200672
   7!:2 'a=. i.10000'
80364
   7!:2 '+/ a'
120392
So it's fairly clear where the space is going. 

-- 
Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov

