- Programming for Speed
- 01 Sep 2006 07:51:59 pm
- Last edited by b-flat on 01 Sep 2006 07:58:51 pm; edited 1 time in total
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:
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).
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).