}
assertTrue("count was bad: " + count, count > 100 && count < orig.length / 2);
System.out.println("float array with " + count + " out of " + orig.length
+ " non-zero values");
SparseFloatArray sparse = new SparseFloatArray(orig);
for (int i = 0; i < orig.length; i++) {
float o = orig[i];
float s = sparse.get(i);
assertTrue("orig " + o + " wasn't the same as sparse: " + s + " for i = " + i, o == s);
}
// things came out correct
long markTime = System.currentTimeMillis();
for (int i = 0; i < orig.length; i++) {
@SuppressWarnings("unused")
float f = orig[i];
}
long elapsedTimeOrig = System.currentTimeMillis() - markTime;
markTime = System.currentTimeMillis();
for (int i = 0; i < orig.length; i++) {
sparse.get(i);
}
long elapsedTimeSparse = System.currentTimeMillis() - markTime;
double ratio = (double) elapsedTimeSparse / (double) elapsedTimeOrig;
System.out.println("fyi on speed, direct array access took " + elapsedTimeOrig