Page 5 of 12

Posted: Wed 30 Mar, 2005 12:50 am
by digiTsai
crap i had to register :(
O well, at least there wasn't an activation email


You could try factoring, though I do not know if it will be faster

Code: Select all

X+7(Ans=26)-7(Ans=24->X 
to

Code: Select all

X+7((Ans=26)-(Ans=24->X 
There are a few places you could factor at.


Virtuoso

Posted: Wed 30 Mar, 2005 1:05 am
by MooK
prgmPerson (at this moment) is only called when a key is pressed. (It is an image of the sprite facing towards the user. I hope to animate it, but I have not yet gotten there, so maybe I will put it in the program for now. Thanks
I am not sure about the factoring, but I will try it, thanks.

Posted: Wed 30 Mar, 2005 1:16 am
by digiTsai

Code: Select all

If Ans>86 or Ans<0:Then
Ans+7(Ans<=1)-7(Ans>=87->X
End 
Why do you have a Then and an End there?

Posted: Wed 30 Mar, 2005 1:20 am
by MooK
I was told that when one uses If:Then End instead of If:Then that the execution is faster. Well, someone actually tested it, and for my program (where that if evaluates to false most of the time) it is faster.

Posted: Wed 30 Mar, 2005 1:22 am
by digiTsai
I found another one

instead of

Code: Select all

While 1
If Ans
Then
commands
End
End
Do this:

Code: Select all

While 1
If not(Ans
End
commands
End

Posted: Wed 30 Mar, 2005 1:26 am
by MooK
Ok lemme try that one out.
Seems faster :D Thanks

Posted: Wed 30 Mar, 2005 1:33 am
by MooK
Hmmm....is
Getkey:Ans->A
faster than
Getkey->A
?

Posted: Wed 30 Mar, 2005 1:34 am
by digiTsai
I dunno if this will be faster. It does bring it down by 1 byte though (2 if you do it for the "y" also)

Code: Select all

X+7(Ans=26)-7(Ans=24->X
If Ans>86 or Ans<0:Then
Ans+7(Ans<=1)-7(Ans>=87->X
End 
To

Code: Select all

X+7(Ans=26)-7(Ans=24
If Ans>86 or Ans<0:Then
Ans+7(Ans<=1)-7(Ans>=87
End
Ans->X

Posted: Wed 30 Mar, 2005 1:38 am
by MooK
I am guessing that that might slow it down. I just tested the getkey thing I was wondering about...The first method (getkey->A) is 1.36 times faster, so going by that I think the new thing would slow the program down a little. I will remember that though, because I might optimize it for size later on, thanks.

Posted: Wed 30 Mar, 2005 1:45 am
by digiTsai
How do you test the speed of your programs?

Posted: Wed 30 Mar, 2005 1:48 am
by DarkerLine
Say you want to test if randInt(0,10 or int(11rand is faster. You make the following program:

Code: Select all

For(I,1,2000
randInt(0,10
End
Pause "randInt( DONE
For(I,1,2000
int(11rand
End
"int(rand DONE
then you dig out a stopwatch and time it.

Posted: Wed 30 Mar, 2005 1:52 am
by MooK
That is what I did with the getkey, but for the others I tired to time the speed of the sprite moving across the screen...heh...bad move. I think I will go back and test everything again...

Posted: Wed 30 Mar, 2005 3:27 am
by MooK
...Wait a second. I just inputed
:If 0<X<86:Then
Blah Blah Blah



Does that actually work?



*edit* Oh yeah, I just tested
If X>86 or X<0:X+7(X<=1)-7(X>=87->X
Vs
X+7(X<=1)-7(X>=87->X

The latter wins. Then I did this
If X>86 or X<0:Then
X+7(X<=1)-7(X>=87->X
End
Vs
X+7(X<=1)-7(X>=87->X
Again the latter one wins :shock: But it was closer this time.

I am not sure how to test ...Any suggestions?

Code: Select all

While 1
If Ans
Then
commands
End
End
VS

Code: Select all

While 1
If not(Ans
End
commands
End

Posted: Wed 30 Mar, 2005 3:33 pm
by merthsoft
...Wait a second. I just inputed
:If 0<X<86:Then
Blah Blah Blah



Does that actually work?
Wholy crap, it does...

Posted: Wed 30 Mar, 2005 4:39 pm
by digiTsai
I think it does this
(0<X)<86

So if it is greater than 0, then the 0<X will be the value 1

Im not sure though