1. puzzled
- Posted by Jiri Babor <J.Babor at GNS.CRI.NZ> Sep 09, 1999
- 580 views
Anybody, please, but Rob in particular: Why is the new 'short circuit' evaluation in the following code fragment so much slower than its emulation? I get a factor of 3 or 4 on my machines! Is it the 'logical or' that's so expensive? What's going on? jiri (puzzled -- snip -------------------------------------------------------------- include machine.e -- tick_rate constant n=1000000 atom dt,t integer a,b,c tick_rate(200) c=9 -- empty loop t=time() for i=1 to n do end for dt=time()-t -- old: a=0 b=0 t=time() for i=1 to n do if c=32 then a=a+1 elsif c=9 then a=a+1 else b=b+1 end if end for t=time()-t-dt ?t -- new: a=0 b=0 t=time() for i=1 to n do if c=32 or c=9 then a+=1 else b+=1 end if end for t=time()-t-dt ?t
2. Re: puzzled
- Posted by "Brian K. Broker" <bkb at CNW.COM> Sep 08, 1999
- 501 views
Your example will not short circuit but even if you change the example so that it does short circuit (see my changes in your code below), the first example runs a bit more than twice the speed of the second. I guess there's a trade off between less code and longer execution time... (not that my analysis answered your question...) -- Brian On Thu, 9 Sep 1999, Jiri Babor wrote: > Anybody, please, but Rob in particular: > > Why is the new 'short circuit' evaluation in the following code > fragment so much slower than its emulation? I get a factor of 3 or 4 > on my machines! Is it the 'logical or' that's so expensive? What's > going on? jiri (puzzled > > -- snip -------------------------------------------------------------- > > include machine.e -- tick_rate > > constant > n=1000000 > atom dt,t > integer a,b,c > > tick_rate(200) > c=9 > > -- empty loop > t=time() > for i=1 to n do > end for > dt=time()-t > > -- old: > a=0 b=0 > t=time() > for i=1 to n do > if c=9 then a=a+1 -- was c=32 > elsif c=32 then a=a+1 -- was c=9 > else b=b+1 > end if > end for > t=time()-t-dt > ?t > > -- new: > a=0 b=0 > t=time() > for i=1 to n do > if c=9 or c=32 then a+=1 -- was c=32 or c=9 > else b+=1 > end if > end for > t=time()-t-dt > ?t >
3. Re: puzzled
- Posted by Robert Craig <rds at ATTCANADA.NET> Sep 08, 1999
- 484 views
- Last edited Sep 09, 1999
Jiri Babor writes: > Why is the new 'short circuit' evaluation in the following code > fragment so much slower than its emulation? I get a factor of > 3 or 4 on my machines! Is it the 'logical or' that's so expensive? > What's going on? jiri (puzzled I get a factor of 2.1 on my Pentium-150. faster: > if c=32 then a=a+1 > elsif c=9 then a=a+1 > else b=b+1 > end if slower: > if c=32 or c=9 then a+=1 > else b+=1 > end if A long time ago I carefully optimized the case of comparing two things that are known (at compile-time) to be integers, then using the result of the comparison in an if/elsif/while. When I did short-circuit evaluation, I opted for a very safe and simple implementation. I was afraid of introducing subtle bugs into people's existing code. Since no short-circuit bugs have been reported so far, I guess I could try to be more aggressive in optimizing it. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
4. Re: puzzled
- Posted by Jiri Babor <J.Babor at GNS.CRI.NZ> Sep 09, 1999
- 489 views
Sorry, Brian, you are right, bad example. Fortunately it did not make much difference. Earlier today I noticed that a revamp of my string functions (trim, etc) runs much slower than the older version. In the original code, the variable c could, of course, have any char value. I just picked wrong one... Rob, I suspected that might be the case. Please fix it. Btw, this sort of things makes Euphoria an infuriating playing field: goal posts shifting around all the time. But I guess it also means it is still alive, developing... Thanks, guys. jiri
5. puzzled
- Posted by "BABOR, JIRI" <J.Babor at GNS.CRI.NZ> Jul 16, 1997
- 504 views
What's the point of sending shrouded demos to this list? Jiri
6. Re: puzzled
- Posted by mark honnor <m.honnor at XTRA.CO.NZ> Jul 16, 1997
- 501 views
BABOR, JIRI wrote: > > What's the point of sending shrouded demos to this list? Jiri 1 : i wanted to show some one what i made, 2 : it is not worth putting it on the RDS page, 3 : I accidentaly shrouded OVER my original code so all i have is the shrouded version, 4 : To my knowledge, no one has died as a direct result of my posting this program :) --Augorian;
7. Re: puzzled
- Posted by Michael Packard <lgp at EXO.COM> Jul 15, 1997
- 572 views
- Last edited Jul 16, 1997
On Wed, 16 Jul 1997, mark honnor wrote: > 3 : I accidentaly shrouded OVER my original code so all i have is the > shrouded version, D'oh! good to see I'm NOT the only IDIOT around here! Socrates. <walking away, shaking his head in disgust, laughing hysterically> Michael Packard Lord Generic Productions lgp at exo.com http://exo.com/~lgp A Crash Course in Game Design and Production http://exo.com/~lgp/euphoria
8. Re: puzzled
- Posted by Faerun McLeam <photek.maven.gov at JUNO.COM> Jul 16, 1997
- 598 views
The last game ends before anyone wins. On Wed, 16 Jul 1997 10:07:36 +1200 mark honnor <m.honnor at xtra.co.nz> writes: >---------------------- Information from the mail header >----------------------- >Sender: Euphoria Programming for MS-DOS ><EUPHORIA at MIAMIU.ACS.MUOHIO.EDU> >Poster: mark honnor <m.honnor at XTRA.CO.NZ> >Subject: Re: puzzled >------------------------------------------------------------------------------- > >BABOR, JIRI wrote: >> >> What's the point of sending shrouded demos to this list? Jiri > >1 : i wanted to show some one what i made, >2 : it is not worth putting it on the RDS page, >3 : I accidentaly shrouded OVER my original code so all i have is the >shrouded version, >4 : To my knowledge, no one has died as a direct result of my posting >this program :) > >--Augorian; > Jiri is right, I got a decoder, I have version 1.4, your code doesn't work I want to kill you. BTW what was it supposed to do. Next time Just send it plain if it is not a zip or such with an indication of where to "cut". That would make life easier. Thanx Me