SNOWFLAKES DRAWING PAPER

[AS] 문자열 더하기 방법 성능비교! 본문

개발/FLEX/AS3/AIR/BlazeDS

[AS] 문자열 더하기 방법 성능비교!

눈송2 2008. 11. 1. 07:52


문자열 더하기 방법 성능비교!
http://cafe.naver.com/flex4u/1092


첫번째

 for (var i:int = 0; i < 500000; ++i ){
     testString += [문자열1]
     + [문자열2]
     + [문자열3];
    }





두번째

testArr = [];
    for (var j:int = 0; j < 500000; ++j ){
     
     testArr.push([문자열1]);
     testArr.push([문자열2]);
     testArr.push([문자열3]);
     
    }
    testString = testArr.join("");



세번째


for (var k:int = 0; k < 500000; ++k ){
     testString += new String().concat(
       [문자열1]
      ,[문자열2]
      ,[문자열3]);
    }





결과 >>

문자열1 = "aaaaaaaaaa"
문자열2 = "bbbbbbbbbb"
문자열3 = "cccccccccc"
첫번째 걸린시간 : 535ms
두번째 걸린시간 : 723ms
세번째 걸린시간 : 1191ms


문자열1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
문자열2 = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
문자열3 = "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
첫번째 걸린시간 : 3466ms
두번째 걸린시간 : 582ms
세번째 걸린시간 : 3923ms





Comments