T
ar
(
N
)
= 23.0918E − 6 $ N + 16.948E − 3
Tav
(
N
)
= 23.1404E − 6 $ N + 10.368E − 3
where N is the number of list elements, so
T
ar
(
N
)
− T
av
(
N
)
= 48.6E − 9 $ N + 6.58E − 3
The small N coefficient can be ignored. More timing experiments give
Tcr = 16.9 mS
So the equation simplifies to [5]
N
c
N
a
=
6.58 mS
T
cv
−16.9 mS
For example, for a list of 100 elements, equation [4] gives Tcv = 83.91 mS. If three elements are
accessed each function call (Na = 3), then Nc is 0.29, which means that the reference method is
always faster. If all 100 elements are accessed each call (Na = 100), then Nc = 9.8, which means that
the reference method will be faster when the function is called at least 10 times.
I mentioned above that the element access time also depends on the size of the list. For a list
consisting of 250 elements, it takes about 16 mS to access element [1], 22 mS for element [125], and
28 mS for element [250]. This is substantial variation, which means that the mean timing results above
apply only if the probabilities of accessing any particular elements are equal. If you know that your
application tends to access elements at a particular list index, you need to account for that in the
break-even analysis.
Execution time data for matrix element accesses
This section shows the test data for matrix element access times. All times are for a TI-92 Plus, HW2,
AMS 2.05. The test matrices are created with randmat(), so the matrix elements are floating point
integers. The mode settings for the tests are RAD and APPROX.
Table 1 shows the time required to access a single matrix element when the matrix indices are
constants, for example, matrix[1,1]. The test data shows that the overhead to access a matrix element
with the reference method (by indirection) is about 5.3 mS. The data also shows the access time
variation with respect to the size of the matrix, and the element's position in the matrix.
Table 1
Matrix element access time, constant indices
5.428.222.8[10,10]
5.723.417.7[5,5]
5.219.414.2[1,1]20 rows, 20 columns
5.224.519.3[10,10]
5.121.816.7[5,5]
4.919.214.3[1,1]10 rows, 10 columns
Reference method
overhead
Tar - Tav
Access time Tar,
reference method
(mS)
Access time Tav,
value method
(mS)
Element
accessedMatrix dimensions
7 - 49