티스토리 뷰
반응형
public class Pad {
public static void main(String[] args){
long start = System.currentTimeMillis();
int count = Integer.MAX_VALUE;
long ret = 0L;
for (int i = 0; i < count; i++) {
ret++;
}
long end = System.currentTimeMillis();
System.out.println((end-start)/1000.0);
}
}

public class Pad {
public static void main(String[] args){
long start = System.currentTimeMillis();
int count = Integer.MAX_VALUE;
long ret = 0L;
for (int i = 0; i < count; i++) {
ret+=1;
}
long end = System.currentTimeMillis();
System.out.println((end-count)/1000.0);
}
}

결론: 결과는 유사하게 나온다.
우선 같은 이유는 컴파일 시에 같은 바이트코드로 변환된다는 점. 그래서 비슷한 결과값을 가진다.
뻘 짓 끝
반응형
'JVM > JAVA' 카테고리의 다른 글
| [JAVA] Exception에 대하여 (0) | 2021.11.25 |
|---|---|
| [JAVA] 인터페이스에 대해서 (0) | 2021.11.20 |
| [JAVA] 클래스 변수를 잘 활용하라!(불필요한 객체 생성을 피하라) (0) | 2021.11.19 |
| [JAVA] 반복문, 조건문 놓치기 쉬운 것들 (0) | 2021.10.26 |
| [JAVA] 쉬프트 연산자와 일반 연산자 속도 차이 (0) | 2021.10.22 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 알고리즘
- docker-compose
- Pattern
- Collections
- Spring
- django
- 2021 KAKAO BLIND RECRUITMENT
- DRF
- 카카오
- 프로그래머스
- PostgreSQL
- postgres
- 면접
- Java
- Python
- ubuntu
- dockerignore
- headers
- thread
- 파이썬
- docker
- 그래프
- Celery
- Linux
- setattr
- 백준
- env
- BFS
- Command Line
- 자바
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
글 보관함