import java.util.List;
public class Test {
static int current;
public static void main(String[] args) {
final int LOOP_COUNT = 10000;
List<Integer> list = new ArrayList<Integer>(LOOP_COUNT);
for (int i = 0; i < LOOP_COUNT; i++) {
list.add(i);
}
long startTime = System.nanoTime();
int listSize = list.size();
for (int i = 0; i < listSize; i++) {
resultProcess(list.get(i));
}
long endTime = System.nanoTime();
double elaspedTime = (endTime - startTime) / 1000000.0;
System.out.println(elaspedTime);
startTime = System.nanoTime();
for (int i = 0; i < list.size(); i++) {
resultProcess(list.get(i));
}
endTime = System.nanoTime();
elaspedTime = (endTime - startTime) / 1000000.0;
System.out.println(elaspedTime);
startTime = System.nanoTime();
for (Integer i : list) {
resultProcess(i);
}
endTime = System.nanoTime();
elaspedTime = (endTime - startTime) / 1000000.0;
System.out.println(elaspedTime);
}
public static void resultProcess(int result) {
current = result;
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.