*실행시간
long start = System.currentTimeMillis();        //시작하는 시점 계산
long end = System.currentTimeMillis();         //프로그램이 끝나는 시점 계산
System.out.println("실행 시간 : " + ( end - start )/1000.0 +"초");          //실행 시간 계산 및 출력


 


*메모리 사용량
Runtime.getRuntime().gc();
// 비교 직전에 gc 를 사용해서 garbage collection을 실행하도록 하면 보다 더 정확하게 메모리 소비량을 얻을 수 있다. 
long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.out.println("used memory is " + used + " bytes");

'JAVA' 카테고리의 다른 글

5. 생성자(Constructor)  (0) 2020.04.28
4. 상속(extends)과 구성(composition)  (0) 2020.04.28
0.자바에 대하여  (0) 2020.04.24
3.JVM(Java Virtual Machine)  (0) 2020.04.23
2.컴파일(Compile)  (0) 2020.04.23

+ Recent posts