1. IF / WHILE / FOR
- Posted by "Daniel Kluss" <xerox_irs at hotmail.com> Jun 10, 2004
- 443 views
I remember hearing a while ago about "while 1 do" being omptimized somehow= =20 in euphoria, and was wondering if "if 1 then / if 0 then" or even "for " ar= e=20 similarly optimized. I'm wondering if a bunch of "if <constant> then" 's can be done with no=20 penalty in speed. Daniel =20 Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
2. Re: IF / WHILE / FOR
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 11, 2004
- 446 views
Daniel Kluss wrote: > I remember hearing a while ago about "while 1 do" being omptimized > somehow in euphoria, and was wondering if "if 1 then / if 0 then" or > even "for " are similarly optimized. > I'm wondering if a bunch of "if <constant> then" 's can be done with no > penalty in speed. "while 1 do" is optimized to nothing (no code) in the interpreter and translator (an infinite loop is set up that requires "exit" or "return" to get out). You'll be able to see this for yourself when I release the Euphoria in Euphoria source. The other cases above aren't fully optimized. I plan to optimize "if 0 then" and "if 1 then" by deleting all the code in the case that won't be executed. If you use the translator, there's a good chance that the C compiler will do this optimization anyway. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: IF / WHILE / FOR
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 12, 2004
- 431 views
On Thu, 10 Jun 2004 16:25:33 -0700, Daniel Kluss <xerox_irs at hotmail.com> wrote: > > >I remember hearing a while ago about "while 1 do" being omptimized somehow >in euphoria, and was wondering if "if 1 then / if 0 then" or even "for " are >similarly optimized. >I'm wondering if a bunch of "if <constant> then" 's can be done with no >penalty in speed. > As it happens, I tested this the other week (as I've done just this on my other, far from complete project [ask me privately, or on openEU, not here]), and the penalty is there, on RDS Eu, albeit small. As Rob said, this is on his todo list. However, I have to ask, what would you want optimised with a for loop? I almost get it, but I'd like a real/believable example, since I imagine that bothering to do this on a for loop might not be very useful, since it is likely to be extremely rare. Regards, Pete PS Blueyonder (my ISP) is experiencing email problems nationwide at the moment, which they seem to be having some difficulty addressing.
4. Re: IF / WHILE / FOR
- Posted by "Daniel Kluss" <xerox_irs at hotmail.com> Jun 12, 2004
- 428 views
Well I was mainly talking about "if" and "while", but the idea is having= =20 constants at the top a program, and changing them for different=20 test/purposes and having the program react appropriatly. I just didn't want bad speed cause of testing/not testing and leaving=20 testing code in place. example if DEBUGMODE then--if debugnumber is 0 then if dissappears do lots of junk end if --if debugnumber is 0 then forloop dissapears for i = 1 to DEBUGNUMBER do end for and while too Daniel >From: Pete Lomax <petelomax at blueyonder.co.uk> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: IF / WHILE / FOR >Date: Sat, 12 Jun 2004 01:32:35 +0100 > > >On Thu, 10 Jun 2004 16:25:33 -0700, Daniel Kluss ><xerox_irs at hotmail.com> wrote: > > > > >I remember hearing a while ago about "while 1 do" being omptimized=20 >somehow > >in euphoria, and was wondering if "if 1 then / if 0 then" or even "for "= =20 >are > >similarly optimized. > >I'm wondering if a bunch of "if <constant> then" 's can be done with no > >penalty in speed. > > >As it happens, I tested this the other week (as I've done just this on >my other, far from complete project [ask me privately, or on openEU, >not here]), and the penalty is there, on RDS Eu, albeit small. As Rob >said, this is on his todo list. > >However, I have to ask, what would you want optimised with a for loop? >I almost get it, but I'd like a real/believable example, since I >imagine that bothering to do this on a for loop might not be very >useful, since it is likely to be extremely rare. > >Regards, >Pete >PS Blueyonder (my ISP) is experiencing email problems nationwide at >the moment, which they seem to be having some difficulty addressing. > > > > =20 Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
5. Re: IF / WHILE / FOR
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 12, 2004
- 427 views
On Sat, 12 Jun 2004 11:51:06 -0700, Daniel Kluss <xerox_irs at hotmail.com> wrote: >if DEBUGMODE then--if debugnumber is 0 then if dissappears >do lots of junk >end if Yep, if debugmode is a constant, the if statement should disappear in either case, but if debugmode=0 the contents should disappear too (as said, this is "Not Yet in RDS Eu"). >--if debugnumber is 0 then forloop dissapears >for i = 1 to DEBUGNUMBER do >end for Thanks. I suppose that is pretty obvious really, but for some reason I couldn't get my head round it. I had been stuck along the lines of eg: for i=1 to debug*length(mytable) do as shorthand for: if debug then for i=1 to length(mytable) do Which was failing to convince me it was really worth doing. (Although to be fair the for loop remains low prioritywise.) Regards, Pete