1. loops & perfomace
- Posted by martin.stachon at worldonline.cz Apr 28, 2001
- 392 views
This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C0CFDA.F95FD000 charset="iso-8859-2" Hi, i've got an performace question. We've got a loop for i=3D1 to length(s) do ... end for is length(s) evaluated every time loop is done? So would be in Euphoria = faster l=3D length(s) for i=3D1 to l do ... end for as i read in one C book? ------=_NextPart_000_0005_01C0CFDA.F95FD000 Content-Type: text/html; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-2" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3D"Arial CE" size=3D2>Hi,</FONT></DIV> <DIV><FONT face=3D"Arial CE" size=3D2>i've got an performace question. = We've got a=20 loop</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DCourier size=3D2>for i=3D1 to length(s) = do</FONT></DIV> <DIV><FONT face=3DCourier=20 size=3D2> ...</FONT></DIV> <DIV><FONT face=3DCourier size=3D2>end for</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3D"Arial CE" size=3D2>is length(s) evaluated every time = loop is=20 done? So would be in Euphoria faster</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DCourier size=3D2>l=3D length(s)</FONT></DIV> <DIV><FONT face=3DCourier size=3D2>for i=3D1 to l do</FONT></DIV> <DIV><FONT face=3DCourier size=3D2> ...</FONT></DIV> <DIV><FONT face=3DCourier size=3D2>end for</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3D"Arial CE" size=3D2>as i read in one C = book?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3D"Arial CE"=20 ------=_NextPart_000_0005_01C0CFDA.F95FD000--
2. Re: loops & perfomace
- Posted by Ted Fines <fines at macalester.edu> Apr 28, 2001
- 365 views
I don't think it makes a difference. Euphoria would appear to be executing the for loop the 'smart' way. I did a quick test with this code-- sequence s s=repeat(32,50000000) atom a,t0,loop_overhead integer lengthofs t0=time() lengthofs=length(s) for c=1 to lengthofs do a=power(2,20) end for loop_overhead=time()-t0 puts(1,sprintf("%d seconds",loop_overhead)) ...and then tried it, replacing this line: for c=1 to lengthofs do with this one: for c=1 to length(s) do and it ran at the same speed. This code was just lifted from the docs located in C:\EUPHORIA\HTML\LIB_S_T.HTM, and slightly modified... --Ted --On Saturday, April 28, 2001 12:01 PM +0200 martin.stachon at worldonline.cz wrote: > > > > Need a better decision-making tool to research, evaluate and > select software for enterprise applications or manufacturing > point solutions? Masg.com is where you'll find help. > > > Hi, > i've got an performace question. We've got a loop > > for i=1 to length(s) do > ... > end for > > is length(s) evaluated every time loop is done? So would be in Euphoria > faster > > l= length(s) > for i=1 to l do > ... > end for > > as i read in one C book? > > >
3. Re: loops & perfomace
- Posted by Derek Parnell <ddparnell at bigpond.com> Apr 28, 2001
- 365 views
With the quick test I did below, the times seem to say that length() is faster than integer! But only one tenth of a second over 67 million iterations. So I would worry about it. --------------- atom e integer aa sequence ss, x ss = "jhsdkjahsh akshdkjahsdkjaskjdaskhjdakjsdhkjashdkjahskdjhaksjdhkasdh" x={} aa = length(ss) e = time() for j = 1 to 1000000 do for i =1 to length(ss) do x = append(x,ss) x = {} end for end for ? time() - e ? aa --------------- ------ Derek Parnell Melbourne, Australia "To finish a job quickly, go slower." ----- Original Message ----- From: martin.stachon at worldonline.cz To: EUforum Sent: Saturday, April 28, 2001 8:01 PM Subject: loops & perfomace Hi, i've got an performace question. We've got a loop for i=1 to length(s) do ... end for is length(s) evaluated every time loop is done? So would be in Euphoria faster l= length(s) for i=1 to l do ... end for as i read in one C book? ----------------------------------------
4. Re: loops & perfomace
- Posted by martin.stachon at worldonline.cz Apr 28, 2001
- 362 views
Euphoria is smarter than C... ----- Original Message ----- From: Ted Fines <fines at macalester.edu> Subject: Re: loops & perfomace > > > > > I don't think it makes a difference. Euphoria would appear to be executing > the for loop the 'smart' way. I did a quick test with this code-- > > sequence s > s=repeat(32,50000000) > atom a,t0,loop_overhead > integer lengthofs > > t0=time() > lengthofs=length(s) > for c=1 to lengthofs do > a=power(2,20) > end for > loop_overhead=time()-t0 > puts(1,sprintf("%d seconds",loop_overhead)) > > ...and then tried it, replacing this line: > for c=1 to lengthofs do > with this one: > for c=1 to length(s) do > > and it ran at the same speed. > > This code was just lifted from the docs located in > C:\EUPHORIA\HTML\LIB_S_T.HTM, and slightly modified... > > --Ted > > --On Saturday, April 28, 2001 12:01 PM +0200 martin.stachon at worldonline.cz > wrote: > > > > > > > > > Need a better decision-making tool to research, evaluate and > > select software for enterprise applications or manufacturing > > point solutions? Masg.com is where you'll find help. > > > > > > Hi, > > i've got an performace question. We've got a loop > > > > for i=1 to length(s) do > > ... > > end for > > > > is length(s) evaluated every time loop is done? So would be in Euphoria > > faster > > > > l= length(s) > > for i=1 to l do <snip> > > > > > >
5. Re: loops & perfomace
- Posted by jbrown105 at HotPOP.com Apr 28, 2001
- 374 views
Probally because Eu saves the data from length into an int, but doesn't for the eu-integer type. P.S. Off topic from message thread, anyone know any good guis for "Euphoria for Linux"? jbrown On Sun, Apr 29, 2001 at 02:34:42AM +1000, Derek Parnell wrote: >=20 >=20 > With the quick test I did below, the times seem to say that length() is > faster than integer! But only one tenth of a second over 67 million > iterations. So I would worry about it. >=20 > --------------- > atom e >=20 > integer aa > sequence ss, x >=20 > ss =3D "jhsdkjahsh akshdkjahsdkjaskjdaskhjdakjsdhkjashdkjahskdjhaksjdhkas= dh" > x=3D{} > aa =3D length(ss) > e =3D time() > for j =3D 1 to 1000000 do > for i =3D1 to length(ss) do > x =3D append(x,ss) > x =3D {} > end for > end for >=20 > ? time() - e > ? aa > --------------- >=20 > ------ > Derek Parnell > Melbourne, Australia > "To finish a job quickly, go slower." >=20 > ----- Original Message ----- > From: martin.stachon at worldonline.cz > To: EUforum > Sent: Saturday, April 28, 2001 8:01 PM > Subject: loops & perfomace >=20 >=20 >=20 > Hi, > i've got an performace question. We've got a loop >=20 > for i=3D1 to length(s) do > ... > end for >=20 > is length(s) evaluated every time loop is done? So would be in Euphoria > faster >=20 > l=3D length(s) > for i=3D1 to l do > ... > end for >=20 > as i read in one C book? >=20 > ---------------------------------------- >=20 >=20 >=20 >=20 >=20 > =3D=3D^=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= >=20 <snip> --=20 Linux User:190064 Linux Machine:84163 http://jbrown105.1avenue.com
6. Re: loops & perfomace
- Posted by Euman <euman at bellsouth.net> Apr 28, 2001
- 379 views
This is a multi-part message in MIME format. ------=_NextPart_000_0024_01C0CFF0.02A2D3A0 charset="iso-8859-2" It also states in the Euphoria performance docs to save values where you can I did a test of length( ) and found that if I got the length of a sequence OUTSIDE the loop first that this was the faster method... Euman ----- Original Message ----- From: martin.stachon at worldonline.cz To: EUforum Sent: Saturday, April 28, 2001 05:01 Subject: loops & perfomace Hi, i've got an performace question. We've got a loop for i=1 to length(s) do ... end for is length(s) evaluated every time loop is done? So would be in Euphoria faster l= length(s) for i=1 to l do ... end for as i read in one C book? ---------------------------------------- ------=_NextPart_000_0024_01C0CFF0.02A2D3A0 Content-Type: text/html; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-2"> <META content=3D"MSHTML 6.00.2462.0" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>It also states in the Euphoria = performance docs to=20 save values where you can</FONT></DIV> <DIV><FONT face=3DArial size=3D2>I did a test of length( ) and found = that if I got=20 the length of a sequence</FONT></DIV> <DIV><FONT face=3DArial size=3D2>OUTSIDE the loop first that this was = the faster=20 method...</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV>Euman</DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Dmartin.stachon at worldonline.cz=20 = href=3D"mailto:martin.stachon at worldonline.cz">martin.stachon at worldonline.= cz</A>=20 </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = title=3DEUforum at topica.com=20 href=3D"mailto:EUforum at topica.com">EUforum</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Saturday, April 28, 2001=20 05:01</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> loops & = perfomace</DIV> </PRE><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Need a better decision-making tool to research, evaluate and select software for enterprise applications or manufacturing point solutions? Masg.com is where you'll find help. <A = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</PRE> <DIV><FONT face=3D"Arial CE" size=3D2>Hi,</FONT></DIV> <DIV><FONT face=3D"Arial CE" size=3D2>i've got an performace question. = We've got a=20 loop</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DCourier size=3D2>for i=3D1 to length(s) = do</FONT></DIV> <DIV><FONT face=3DCourier=20 size=3D2> ...</FONT></DIV> <DIV><FONT face=3DCourier size=3D2>end for</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3D"Arial CE" size=3D2>is length(s) evaluated every = time loop is=20 done? So would be in Euphoria faster</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DCourier size=3D2>l=3D length(s)</FONT></DIV> <DIV><FONT face=3DCourier size=3D2>for i=3D1 to l do</FONT></DIV> <DIV><FONT face=3DCourier size=3D2> ...</FONT></DIV> <DIV><FONT face=3DCourier size=3D2>end for</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3D"Arial CE" size=3D2>as i read in one C = book?</FONT></DIV> <DIV> </DIV> Window? Not=20 yet. First, check our technology forum for help. <A=20 = = href=3D"http://topica.com/u/?b1dd66.b2lJ88">http://topica.com/u/?b1dd66.b= 2lJ88</A> Or send an email To: EUforum-unsubscribe at topica.com This email was sent to: euman at bellsouth.net <A = =3D=3D^=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= ------=_NextPart_000_0024_01C0CFF0.02A2D3A0--