Here are a few tests I ran using different functions. I ran the program for one minute, and counted the number of times that it looped through using this code


Code:
:startTmr1
:checkTmr1->A
:DelVar XDelVar K
:While not(K
:checkTmr(1->B
:If B=A+60
:1->K
:10->dim(L3
:1+X->X
:End
:Disp X


Changing this code for the various types of loops, the speeds are shown below (measured in number of loops in a minute):

Lbl/Goto - 1330
While - 1233
Repeat - 1269
For - 1001

Then, I tested adding some common actions to be preformed using the While loop, and got these results:
3->Q - 1178
DelVar Q - 1218
0->Q - 1196
5-L3(1) - 1136
0->L3(1) - 1126
prgmQ (an empty program) - 1149
prgmQ (Return) - 1156
prgmQ (Called parent program) - Could not complete due to memory error.
ClrHome - 762
ClrDraw - 1237
Disp X - 538
Output(1,1,X) - 1117
GetKey->K - 1061
999->dim(L3) - 1172
10->dim(L3) - 1173

Also note that I have a TI-84+ SE and these tests were run with just over 22,800 bytes of RAM. This should be very helpful to anyone that would like to make their programs faster. The "times" can vary by about 5 due to the nature of the timer, but you should be able to get the basic idea.

EDIT: Actually, i forgot to mention something.

A popular idea that was found in the Elite Guide to Basic on ticalc.org was incorrect.

It does not make any difference whether If or If/Then is used - both run at the same speed (I checked this several times).
b-flat wrote:
Actually, i forgot to mention something.

A popular idea that was found in the Elite Guide to Basic on ticalc.org was incorrect.

It does not make any difference whether If or If/Then is used - both run at the same speed (I checked this several times).


Use the EDIT button please Wink
If is slightly faster... it does not have to check for the corresponding End instruction. It is also smaller...


And PLEASE use the edit button next time, plz'kthx.
b-flat wrote:
It does not make any difference whether If or If/Then is used - both run at the same speed (I checked this several times).


If has the significant advantage in that it doesn't need to check for the end, both reducing size and increasing speed.
The smaller one is slightly slower when the condition is false, though.
Overall, I'd say If <condition>:command is generally preferable to If <condition>:Then:command:End.
I completely agree. I just thought I should point that out.
It also give the code a cleaner feel

0x5, I remember when I was first programming I thought hat you had to have an if-then-code-end for every if statement. I made an encryption program as my first one and it was wildly slow. Later when I was more experienced I made a faster one without the then-end. A large number of if-then-end statements is extremely slow compared to a string of if-command statements.


2
I definitely agree with you on that. Not to mention how much more readable it makes your code...
And it is easier to input Rolling Eyes (I did that during choir [shhhhhh], and my hands were almost tired after putting in the if-then-ends for everything Laughing
There's a version of this over on United TI that's a lot more complete.

It's a lot easier just to run startTmr, run a for loop for a certain amount of times, and then Pause checkTmr.
Well, I personaly find it more useful to know the number of times a program can loop in one minute than how long it takes to loop 1000 times (even thought they are comprable). I should probably do that also. Maybe if I add more If/Then statements, the time will actually be different, but when I ran the tests, they came up exactly the same.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement