1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import junit.framework.TestCase;
public class TestValueOf extends TestCase {
public void testValueOf() {
final long start = System.currentTimeMillis();
for (int i = 0; i <= 300000000; i++) {
final int monInt = 10000;
final Integer t = Integer.valueOf(monInt);
}
final long end = System.currentTimeMillis();
System.out.println(end - start);
}
public void testNewInteger() {
final long start = System.currentTimeMillis();
for (int i = 0; i <= 300000000; i++) {
final int monInt = 10000;
final Integer t = new Integer(monInt);
}
final long end = System.currentTimeMillis();
System.out.println(end - start);
}
} |