Difference between revisions of "TI-BASIC:Better Code Timings"
lirtosiast (talk | contribs) m (→Math Commands) |
lirtosiast (talk | contribs) |
||
Line 35: | Line 35: | ||
== List/Matrix Commands == | == List/Matrix Commands == | ||
+ | |||
+ | Unless specified, all list/matrix elements are equal to 1, and all dimensions are equal to 20. | ||
{| class="wikitable" | {| class="wikitable" | ||
− | ! Command !! Iterations !! Average (ms) !! | + | ! Command !! Iterations !! Average (ms) !! Overhead (ms) !! Time (ms)!! Username |
|- | |- | ||
− | | L1 | + | | L1 || 1000 || 2.? || 0.6 || ~2 || 2.55MP/lirtosiast |
|- | |- | ||
− | | not(L1 | + | | not(L1 || 1000 || 9.? || 0.6 || ~9 || 2.55MP/lirtosiast |
|- | |- | ||
− | | L1+0 | + | | L1+0 || 1000 || 20 || 0.6 || ~20 || 2.55MP/lirtosiast |
|- | |- | ||
− | | cumSum(L1 | + | | cumSum(L1 || 1000 || 19 || 0.6 || ~19 || 2.55MP/lirtosiast |
|- | |- | ||
− | | DeltaList(L1 | + | | DeltaList(L1 || 1000 || 26 || 0.6 || ~26 || 2.55MP/lirtosiast |
|- | |- | ||
− | | augment(L1,L1 | + | | augment(L1,L1 || 10000 || 9.4 || 0.6 || 8.8 || 2.55MP/lirtosiast |
|- | |- | ||
− | | augment(L1,{1 | + | | augment(L1,{1 || 10000 || 7.7 || 0.6 || 7.1 || 2.55MP/lirtosiast |
|- | |- | ||
| augment({1},L1 //dim=20 || 10000 || 7.7 || 0.6 || 7.1 || 2.55MP/lirtosiast | | augment({1},L1 //dim=20 || 10000 || 7.7 || 0.6 || 7.1 || 2.55MP/lirtosiast | ||
Line 61: | Line 63: | ||
| Fill(1,L1 //dim=20 || 10000 || 3.9 || 0.6 || 3.3 || 2.55MP/lirtosiast | | Fill(1,L1 //dim=20 || 10000 || 3.9 || 0.6 || 3.3 || 2.55MP/lirtosiast | ||
|} | |} | ||
+ | |||
+ | Below we can see that using the same variable for the seq( variable as the For( variable doesn't slow anything down. The value of the variable before seq( was called is restored in a constant amount of time. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | ! Command !! Iterations !! Average (ms) !! Overhead (ms) !! Time (ms)!! Username | ||
+ | |- | ||
+ | | seq(1,n,1,20 //loop var n || 1000 || 70 || 0.6 || 70 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | seq(1,n,1,20 //loop var X || 1000 || 71 || 1.1 || 70 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | seq(1,X,1,20 //loop var n || 1000 || 82 || 0.6 || 70 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | seq(1,X,1,20 //loop var X || 1000 || 83 || 1.1 || 70 || 2.55MP/lirtosiast | ||
+ | |||
+ | binomcdf(N-1,0 is often used to construct a list of a certain length N, but binompdf( can be slightly faster. The difference is about equal to the time for a call to cumSum(. When called with a second argument that is not 0 or 1, binompdf( slows down dramatically, by a factor of 60. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | ! Command !! Iterations !! Average (ms) !! Overhead (ms) !! Time (ms)!! Username | ||
+ | | binompdf(19,0 || 1000 || 5 || 0.6 || 5 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | binomcdf(19,0 || 1000 || 20 || 0.6 || 20 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | 1 or binompdf(19,0 || 1000 || 16 || 0.6 || 16 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | binompdf(19,1 || 1000 || 5 || 0.6 || 5 || 2.55MP/lirtosiast | ||
+ | |- | ||
+ | | binompdf(19,.5 || 1000 || 296 || 0.6 || 296 || 2.55MP/lirtosiast | ||
+ | |} | ||
+ | |||
{| class="wikitable" | {| class="wikitable" | ||
− | ! Command !! Iterations !! Average (ms) !! | + | ! Command !! Iterations !! Average (ms) !! Overhead (ms) !! Time (ms)!! Username |
|- | |- | ||
| [A]^^T //20x2 || 10000 || 9.3 || 0.6 || 8.7 || 2.55MP/lirtosiast | | [A]^^T //20x2 || 10000 || 9.3 || 0.6 || 8.7 || 2.55MP/lirtosiast |
Revision as of 23:21, 29 March 2016
Instructions
First, write the name and model of your calculator in the table below, then use this code with an empty line in the "test code here" space to measure your loop overhead.
Add the number of iterations you used to the "iterations" column, and [time taken]/[iterations] to the "average" column. Then subtract your loop overhead from the result and list it in the "time" column.
FnOff PlotsOff 0→Xmin 94→Xmax -62→Ymin 0→Ymax DispGraph //if it is a graphing command startTmr→θ Repeat checkTmr(θ End For(𝑛,1,[iterations]) //sequence variable 𝑛; note the closing parenthesis. //test code here End checkTmr(θ+1
Contents
Math Commands
Unless specified, all variables are equal to 1.
Command | Iterations | Average (ms) | Loop overhead (ms) | Time (ms) | Username |
---|---|---|---|---|---|
N=I% and FV=PV | 1000 | 4.? | 0.6 | ~4 | 2.55MP/lirtosiast |
N+FV[i]=I%+PV[i] | 1000 | 7.? | 0.6 | ~7 | 2.55MP/lirtosiast |
List/Matrix Commands
Unless specified, all list/matrix elements are equal to 1, and all dimensions are equal to 20.
Command | Iterations | Average (ms) | Overhead (ms) | Time (ms) | Username |
---|---|---|---|---|---|
L1 | 1000 | 2.? | 0.6 | ~2 | 2.55MP/lirtosiast |
not(L1 | 1000 | 9.? | 0.6 | ~9 | 2.55MP/lirtosiast |
L1+0 | 1000 | 20 | 0.6 | ~20 | 2.55MP/lirtosiast |
cumSum(L1 | 1000 | 19 | 0.6 | ~19 | 2.55MP/lirtosiast |
DeltaList(L1 | 1000 | 26 | 0.6 | ~26 | 2.55MP/lirtosiast |
augment(L1,L1 | 10000 | 9.4 | 0.6 | 8.8 | 2.55MP/lirtosiast |
augment(L1,{1 | 10000 | 7.7 | 0.6 | 7.1 | 2.55MP/lirtosiast |
augment({1},L1 //dim=20 | 10000 | 7.7 | 0.6 | 7.1 | 2.55MP/lirtosiast |
augment({1},{1 | 10000 | 6.0 | 0.6 | 5.4 | 2.55MP/lirtosiast |
DeltaList(L1 //dim=20 | 1000 | 26 | 0.6 | ~26 | 2.55MP/lirtosiast |
Fill(1,L1 //dim=20 | 10000 | 3.9 | 0.6 | 3.3 | 2.55MP/lirtosiast |
Below we can see that using the same variable for the seq( variable as the For( variable doesn't slow anything down. The value of the variable before seq( was called is restored in a constant amount of time.
Command | Iterations | Average (ms) | Overhead (ms) | Time (ms) | Username | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
seq(1,n,1,20 //loop var n | 1000 | 70 | 0.6 | 70 | 2.55MP/lirtosiast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
seq(1,n,1,20 //loop var X | 1000 | 71 | 1.1 | 70 | 2.55MP/lirtosiast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
seq(1,X,1,20 //loop var n | 1000 | 82 | 0.6 | 70 | 2.55MP/lirtosiast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
seq(1,X,1,20 //loop var X | 1000 | 83 | 1.1 | 70 | 2.55MP/lirtosiast
binomcdf(N-1,0 is often used to construct a list of a certain length N, but binompdf( can be slightly faster. The difference is about equal to the time for a call to cumSum(. When called with a second argument that is not 0 or 1, binompdf( slows down dramatically, by a factor of 60.
Home Screen Commands
Graphics Commands
note: multiple commands always on their own line. Loop Overheads
Calculators Used
|