日期:2014-05-18 浏览次数:20806 次
StringBuffer upp = new StringBuffer(),
low = new StringBuffer();
for(int i = 0; i<=9000000; i++){
upp.append("AA");
low.append("aa");
}
long Tupp = System.currentTimeMillis();
upp.toString().toUpperCase();
System.out.println("UPP:"+(System.currentTimeMillis()-Tupp));
long Tlow = System.currentTimeMillis();
low.toString().toUpperCase();
System.out.println("LOW:"+(System.currentTimeMillis()-Tlow));
for(int i = 0; i<=9000000; i++){
upp.append("Aa");
low.append("Aa");
}
//代码块1
long Tupp = System.currentTimeMillis();
upp.toString().toUpperCase();
System.out.println("UPP:"+(System.currentTimeMillis()-Tupp));
//代码块1
//代码块2
long Tlow = System.currentTimeMillis();
low.toString().toLowerCase();
System.out.println("LOW:" + (System.currentTimeMillis() - Tlow));
//代码块2
//代码块3
long Tupp2 = System.currentTimeMillis();
upp.toString().toUpperCase();
System.out.println("UPP:" + (System.currentTimeMillis() - Tupp2));
//代码块3