I have a performance situation at hand.
I have a huge amount of data to be held in memory in a two dimensional table format (12000 X 2000). Now as far as my knowledge goes either I can use int[][] or List<List<Integer>>. And, of course, I access the values using int[i][j] or list.get(i).get(j). I am looping through the entire data at least five times.
Which one do you think will work faster and, if you can answer, why? Also is there any way to speed up the execution?
My java -version gives:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
The OS is Windows Vista.
The array will almost certainly be faster.
Using an
ArrayListwill bring the performance more in-line since it’s backed by an actual array.Edit to summarize comments
For this usecase I believe the arrays will be measurably faster. Whether it’s faster enough to matter is a different issue, and I don’t know enough about the actual problem being solved to make a judgement on that.