0

hi all ,
need to know whether an array with too many indexes or only one index creates difference in processing time?
for example say array $aTotalsMarks

$aTotalsMarks[$sSchool][$sDivision][$iRollNumber][$sExamCode][$sSubject];

And

$aTotalsMarks[$sSchool.'##'.$sDivision.'##'.$iRollNumber.'##'.$sExamCode.'##'.$sSubject];

does the above two arrays make a difference in processing if the number of indexes are increased or decreased ?

thanx.....
-- dg

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Ezzaral
0

Yes, times will differ. Enough to care about? That depends on what you are doing with them.
The first will incur array access costs in accessing the deeper sub-arrays, but working with subsets of information may be faster.
The second is linear, so element access will be faster but you can't process entire subsets without picking out individual elements to work with (depending upon what you intend to do with them).
If these aren't very large arrays it will probably make little difference. If you are working in long loops on them then times could vary greatly, depending upon the operations performed.
Testing is your best friend, write clear concise code that meets your needs first and then optimize it if performance problems warrant it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.