forked from onlybooks/java-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoBoxingPerf.java
More file actions
23 lines (19 loc) · 738 Bytes
/
AutoBoxingPerf.java
File metadata and controls
23 lines (19 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package ch09;
public class AutoBoxingPerf {
public static void main(String[] args) {
long startTime;
// int 원시형 1억 번 계산
startTime = System.currentTimeMillis();
int sum1 = 0;
for (int i = 0; i < 100000000; i++)
sum1 += i;
System.out.printf("int 원시형 1억 번 계산: %s밀리초\n", System.currentTimeMillis() - startTime);
// ---
// Integer 참조형 1억 번 계산
startTime = System.currentTimeMillis();
Integer sum2 = 0;
for (int i = 0; i < 100000000; i++)
sum2 += i;
System.out.printf("Integer 참조형 1억 번 계산: %s밀리초\n", System.currentTimeMillis() - startTime);
}
}