1. Robert faster?
- Posted by Lucius L Hilley III <luciuslhilleyiii at JUNO.COM> Jun 12, 1997
- 626 views
Which would be better? integer width, height sequence s width = 5 height = 10 faster = 1 -- should faster = 1 or 0? if faster then s = repeat(repeat(0, width), height) else s = repeat(height) end if for a = 1 to height do s[a] = {a, a + 1, a + 2, a + 3, a + 4} end for please don't optimize my loop. I just need to know which way this kind of sequence reassignment would be handled better --Lucius Lamar Hilley III -- E-mail at luciuslhilleyiii at juno.com -- I support transferring of files less than 60K. -- I can Decode both UU and Base64 format.
2. Re: Robert faster?
- Posted by Robert Craig <robert_craig at COMPUSERVE.COM> Jun 12, 1997
- 628 views
Lucius Hilley writes: > Which would be better? > integer width, height > sequence s > width =3D 5 > height =3D 10 > faster =3D 1 -- should faster =3D 1 or 0? > if faster then > s =3D repeat(repeat(0, width), height) > else > s =3D repeat(height) = > end if > for a =3D 1 to height do > s[a] =3D {a, a + 1, a + 2, a + 3, a + 4} > end for Instead of: repeat(height) - I assume you mean: repeat(0, height). I haven't timed it, but I'm pretty sure the "repeat(0, height)" method would be faster, i.e. faster =3D 0. When I want to time a small section of code like this, I do the following: atom t t =3D time() for i =3D 1 to 1000 do ... section of code ... end for ? time() - t = If it takes less than a few seconds I increase the "1000" and run it again. (Of course in some cases 1000 would be too large to start with.) Then I modify "section of code" and run it again and compare the times. Perfectionists might also time the for-loop with an *empty* body, so they can deduct the time overhead contributed by the loop mechanism - i.e. incrementing = the loop variable, comparing against the limit, etc. = This is only useful if your section of code takes very little time. = Regards, Rob Craig Rapid Deployment Software
3. Re: Robert faster?
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM> Jun 12, 1997
- 626 views
Lucius wrote: >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS ><EUPHORIA at MIAMIU.ACS.MUOHIO.EDU> >Poster: Lucius L Hilley III <luciuslhilleyiii at JUNO.COM> >Subject: Robert faster? >------------------------------------------------------------------------= -- ----- > >Which would be better? > >integer width, height >sequence s > >width =3D 5 >height =3D 10 >faster =3D 1 -- should faster =3D 1 or 0? >if faster then > s =3D repeat(repeat(0, width), height) >else > s =3D repeat(height) >end if >for a =3D 1 to height do > s[a] =3D {a, a + 1, a + 2, a + 3, a + 4} >end for > >please don't optimize my loop. >I just need to know which way this kind of >sequence reassignment would be handled better > >--Lucius Lamar Hilley III >-- E-mail at luciuslhilleyiii at juno.com >-- I support transferring of files less than 60K. >-- I can Decode both UU and Base64 format. Lucius, Although I'm not Robert, I can give you an advice how to figure out questions like these: Put the alternatives in a loop of, say, 1000 or 100= 00 times, time them and you'll see which one runs faster on your machine! Adriaan Hans Rienks I
4. Re: Robert faster?
- Posted by Lucius L Hilley III <luciuslhilleyiii at JUNO.COM> Jun 12, 1997
- 647 views
On Thu, 12 Jun 1997 12:26:29 -0400 Robert Craig <robert_craig at COMPUSERVE.COM> writes: >Lucius Hilley writes: >> Which would be better? > >> integer width, height >> sequence s > >> width =5 >> height = 10 >> faster = 1 -- should faster =3D 1 or 0? >> if faster then >> s = repeat(repeat(0, width), height) >> else >> s = repeat(0, height) > >> end if >> for a = 1 to height do >> s[a] = {a, a + 1, a + 2, a + 3, a + 4} >> end for >I haven't timed it, but I'm pretty sure the "repeat(0, height)" >method would be faster, i.e. faster = 0. >Regards, > Rob Craig > Rapid Deployment Software > I know how to time them. THANKS My question is more along the lines. Will Euphoria IGNORE the fact that the appropriate amount of 2-Dimensional space has been allocated and then Completely recreate each sequence. You should know the Dynamics of Euphoria. seq = {{0, 0}, {0, 0} Does seq become {0, {0, 0}} {5, 6} to s[1] then becoming {{5, 6}, {0, 0} Or will the allocated space speed up the process. I guess I could call this Points to Ponder. I will be testing the speeds before your next response. --Lucius Lamar Hilley III -- E-mail at luciuslhilleyiii at juno.com -- I support transferring of files less than 60K. -- I can Decode both UU and Base64 format.