日期:2014-05-20 浏览次数:20736 次
public class FFFtest {
public static void main(String[] args) {
int[] a=new int[1000];
int[] b=new int[10000000];
long start = System.currentTimeMillis();
//method 1
for(int i=0;i<1000;i++){
for(int j=0;j<10000000;j++){
a[i]++;
}
}
long end = System.currentTimeMillis();
System.out.println(end-start);
start=System.currentTimeMillis();
//method 2
for(int i=0 ;i<10000000;i++){
for(int j=0;j<1000;j++){
b[i]++;
}
}
end = System.currentTimeMillis();
System.out.println(end-start);
}
}
public static void main(String[] args) {
int[] a=new int[1000];
int[] b=new int[10000000];
long start = System.currentTimeMillis();
//method 1
for(int i=0;i<1000;i++){
for(int j=0;j<10000000;j++){
// a[i]++;
}
}
long end = System.currentTimeMillis();
System.out.print(end-start+"\t");
start=System.currentTimeMillis();
//method 2
for(int i=0 ;i<10000000;i++){
for(int j=0;j<1000;j++){
// b[i]++;
}
}
end = System.currentTimeMillis();
System.out.println(end-start);
}
package test;
public class Test {
static int[] a = new int[100];
static int[] b = new int[100000];
public static void main(final String[] args) throws Exception {
// warm up
for (int i = 0; i < 5000; i++)
method2();
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++)
method2();
long end = System.currentTimeMillis();
System.out.println(end - start);
}
static void method1() {
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100000; j++) {
a[i]++;
}