블로그

ej-technologies의 제품 뉴스, 업데이트 및 인사이트입니다.

RSS로 읽어보세요. 이메일로 구독하세요. 에서 팔로우하세요.

Methods statistics and exceptional method runs

2011-02-12
Ingo Kegel 작성

In the screencast below, I explain how to analyze exceptionally slow invocations of frequently invoked methods. By using the method statistics and exceptional method run features in JProfiler, the slowest invocations are shown separately in the call tree.

The test class that is profiled in this screen cast is given below:

import java.util.Random;
  
public class MethodStatisticsTest {

    private static Random random = new Random(0);

    public static void main(String[] args) {
        while (true) {
            doCriticalTask();
        }
    }

    private static void doCriticalTask() {
        if (random.nextInt(1000) % 999 == 0) {
            implOne();
        } else {
            implTwo();
        }
    }

    private static void implOne() {
        for (int i = 0; i < 100000; i++) {
            Math.sqrt(i);
        }
    }

    private static void implTwo() {
        for (int i = 0; i < 1000; i++) {
            Math.sqrt(i);
        }
    }
}
아카이브