http://verad.tistory.com/entry/Java-%EC%84%B1%EB%8A%A5-%ED%85%8C%EC%8A%A4%ED%8A%B8%EC%8B%9C%EA%B0%84-%EB%A9%94%EB%AA%A8%EB%A6%AC
long time = System.currentTimeMillis();
long time = System.currentTimeMillis();
reportPerformanceFor("starting at", time);
className.Method() //테스트하려는 함수 호출
reportPerformanceFor("graph allocation", time);
reportPerformanceFor("graph allocation", time);
System.out.println("\n" + "Paused: graph is still in memory (to check mem consumption).");
System.out.print("press enter to free memory and finish...");
System.out.print("press enter to free memory and finish...");
try {
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("done.");
private static void reportPerformanceFor(String msg, long refTime)
{
double time = (System.currentTimeMillis() - refTime) / 1000.0;
double mem = usedMemory()
/ (1024.0 * 1024.0);
mem = Math.round(mem * 100) / 100.0;
System.out.println(msg + " (" + time + " sec, " + mem + "MB)");
}
private static void reportPerformanceFor(String msg, long refTime)
{
double time = (System.currentTimeMillis() - refTime) / 1000.0;
double mem = usedMemory()
/ (1024.0 * 1024.0);
mem = Math.round(mem * 100) / 100.0;
System.out.println(msg + " (" + time + " sec, " + mem + "MB)");
}
private static long usedMemory()
{
Runtime rt = Runtime.getRuntime();
{
Runtime rt = Runtime.getRuntime();
return rt.totalMemory() - rt.freeMemory();
}
}
'소스기록장 > java' 카테고리의 다른 글
자바로 만든 리듬게임 - Rhythm and Beat(bms구동기) (19) | 2012.02.25 |
---|---|
[펌] 자바 전체화면 소스 (0) | 2011.11.14 |
간단한 계산기 소스 (2) | 2011.06.12 |