public class Main {
//数据规模增加10倍 消耗的时间
public static void main(String[] args) {
for (int x = 1; x < 10; x++) {
int n = (int) Math.pow(10, x);
double start = System.nanoTime();
int sum = 0;
for (int i = 0; i < n; i++) {
sum += i;
}
double end = System.nanoTime();
System.out.println("total time: " + (end - start) + "ms");
}
}
}
网友评论