IBM RSAEE(Rational Software Analyzer Enterprise Edition)라는 도구는 JAVA 코드를 입력받아 Static analysis를 수행한다.
아래는 대상 샘플 코드이다.
static void test4() {
int l_cnt = 0;
System.out.println(System.currentTimeMillis());
for (; l_cnt < 3000; l_cnt++) {
try {
Thread.sleep(1);
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println(System.currentTimeMillis());
}
static void test5() {
int l_cnt = 0;
System.out.println(System.currentTimeMillis());
try {
for (; l_cnt < 3000; l_cnt++) {
Thread.sleep(1);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(System.currentTimeMillis());
}
test4()결과=>
1244458981930
1244458987790
(5860 msec)
test5()결과=>
1244458987790
1244458993666
(5876 msec)
도구에서는 test4()와 같은 방식을 피할 것을 권고하지만 실제 수행시간은 더 빠르거나 별다른 차이가 없는 듯 하였다.ㅡ.ㅡ;;
다음은 RASEE 에서 설명이다.
Try/catch blocks are necessary to insure proper exception handling, but creating such blocks has performance implications. Since loops contain intensive repetitive computations, it is not recommended to put try/catch blocks inside loops.
'Java Programming' 카테고리의 다른 글
display long value with ',' seperator (0) | 2009.06.29 |
---|---|
loop 안과 밖에서의 obj.class.getName() 사용 performance 비교 (0) | 2009.06.14 |
String vs. StringBuffer vs. StringBuilder (0) | 2009.06.08 |
object reference 전달 (0) | 2009.06.04 |
java heap space 늘리기 (0) | 2009.06.03 |