StringBuffer = function(){
this.arr = new Array();
this.appendChild = function(str){
this.arr.push(str);
}
this.toString = function(){
return this.arr.join("");
}
}
for(var k=1;k<=20;k++){
document.write("NO."+k+"<br>")
var sb = new StringBuffer();
var startDate = new Date();
for(var i=0;i<10000;i++){
sb.appendChild("I");
}
sb.toString();
var endDate = new Date();
document.write(" Use first method:"+(endDate.getTime()-startDate.getTime())+" (milliseconds)<br>");
var str = "";
var startDate2 = new Date();
for(var i=0;i<10000;i++){
str+="I"
}
var endDate2 = new Date();
document.write(" Use second method:"+(endDate2.getTime()-startDate2.getTime())+" (milliseconds)<br>");
}
[quote]
[size=large]Result:[/size]
NO.1
Use first method:47 (milliseconds)
Use second method:313 (milliseconds)
NO.2
Use first method:62 (milliseconds)
Use second method:266 (milliseconds)
NO.3
Use first method:62 (milliseconds)
Use second method:297 (milliseconds)
NO.4
Use first method:47 (milliseconds)
Use second method:297 (milliseconds)
NO.5
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.6
Use first method:47 (milliseconds)
Use second method:297 (milliseconds)
NO.7
Use first method:47 (milliseconds)
Use second method:312 (milliseconds)
NO.8
Use first method:47 (milliseconds)
Use second method:313 (milliseconds)
NO.9
Use first method:47 (milliseconds)
Use second method:312 (milliseconds)
NO.10
Use first method:47 (milliseconds)
Use second method:313 (milliseconds)
NO.11
Use first method:46 (milliseconds)
Use second method:313 (milliseconds)
NO.12
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.13
Use first method:46 (milliseconds)
Use second method:313 (milliseconds)
NO.14
Use first method:47 (milliseconds)
Use second method:328 (milliseconds)
NO.15
Use first method:47 (milliseconds)
Use second method:312 (milliseconds)
NO.16
Use first method:47 (milliseconds)
Use second method:328 (milliseconds)
NO.17
Use first method:47 (milliseconds)
Use second method:297 (milliseconds)
NO.18
Use first method:63 (milliseconds)
Use second method:328 (milliseconds)
NO.19
Use first method:47 (milliseconds)
Use second method:343 (milliseconds)
NO.20
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.21
Use first method:47 (milliseconds)
Use second method:312 (milliseconds)
NO.22
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.23
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.24
Use first method:46 (milliseconds)
Use second method:344 (milliseconds)
NO.25
Use first method:47 (milliseconds)
Use second method:328 (milliseconds)
NO.26
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.27
Use first method:47 (milliseconds)
Use second method:343 (milliseconds)
NO.28
Use first method:63 (milliseconds)
Use second method:328 (milliseconds)
NO.29
Use first method:47 (milliseconds)
Use second method:328 (milliseconds)
NO.30
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.31
Use first method:47 (milliseconds)
Use second method:328 (milliseconds)
NO.32
Use first method:47 (milliseconds)
Use second method:375 (milliseconds)
NO.33
Use first method:46 (milliseconds)
Use second method:344 (milliseconds)
NO.34
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.35
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.36
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.37
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.38
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.39
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.40
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.41
Use first method:47 (milliseconds)
Use second method:344 (milliseconds)
NO.42
Use first method:47 (milliseconds)
Use second method:343 (milliseconds)
NO.43
Use first method:47 (milliseconds)
Use second method:360 (milliseconds)
NO.44
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.45
Use first method:62 (milliseconds)
Use second method:344 (milliseconds)
NO.46
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.47
Use first method:47 (milliseconds)
Use second method:360 (milliseconds)
NO.48
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.49
Use first method:47 (milliseconds)
Use second method:359 (milliseconds)
NO.50
Use first method:47 (milliseconds)
Use second method:375 (milliseconds)
[color=red]Memory:2G
CPU: Inter(R) Pentium(R) Dual Cpu E2200 @2.2GHz[/color]
[/quote]