mmgt; java VectorInd 1000000
Insert Time [749] : 11
Insert Time [61480] : 6
Insert Time [122880] : 48
Insert Time [245760] : 70
Insert Time [491520] : 113
Insert Time [983040] : 215
Insert Time [983917] : 18
Appendix A
[VectorTest.java]
import java.util.Vector;
import java.util.Calendar;
public class VectorTest {
public static void main(String[] args) {
Vector target = new Vector();
String obj = new String("Vector Data");
Calendar start, end;
long interval = 0;
long LIMIT = 0;
int index = 0;
long MAX = Long.parseLong(args[0]);
for ( LIMIT = MAX / 10 ; LIMIT <= MAX ; LIMIT = LIMIT + MAX/10 ) {
start = Calendar.getInstance();
for ( index=0 ; index < LIMIT ; index++) {
target.add(index, obj);
}
end = Calendar.getInstance();
interval = end.getTimeInMillis() - start.getTimeInMillis();
System.out.println(index + " " + interval);
target = new Vector();
}
System.out.println("===========================");
for ( LIMIT = MAX / 10 ; LIMIT <= MAX ; LIMIT = LIMIT + MAX/10 ) {
start = Calendar.getInstance();
for ( index=0 ; index < LIMIT ; index++) {
target.add(0, obj);
}
end = Calendar.getInstance();
interval = end.getTimeInMillis() - start.getTimeInMillis();
System.out.println(index + " " + interval);
target = new Vector();
}
}
}
[VectorInd.java]
import java.util.Vector;
import java.util.Calendar;
public class VectorInd {
public static void main(String[] args) {
Vector target = new Vector(30);
Object obj = new Object();
Calendar start, end;
long interval = 0;
int LIMIT = Integer.parseInt(args[0]);
for ( int index = 0 ; index <= LIMIT ; index++ ) {
start = Calendar.getInstance();
target.add(obj);
end = Calendar.getInstance();
interval = end.getTimeInMillis() - start.getTimeInMillis();
if ( interval > 3 ) {
System.out.println("Insert Time : " + interval);
}
}
}
}
최신 콘텐츠