Java application profiling

后端 未结 4 1279
眼角桃花
眼角桃花 2020-12-15 05:32

I am looking for a Java code profiler which I can use to profile my application (its a service which runs in backend) on production (so means low over head, and it must not

4条回答
  •  臣服心动
    2020-12-15 05:52

    I don't know of any tool which can do profiling without an impact on performance.

    You could add logging to the methods that you're interested in. Make sure you include the time stamp in the log; then you can do the timing. You should also configure the logging framework to log asynchronously to reduce the performance loss.

    A load time weaver like AspectJ is able to add these calls at runtime, which would allow you to easily select the methods you want to monitor without changing the source code all the time.

    Using an around aspect, you can even add timing logging, so you don't have to parse the logs and try to find matching log entries. See this blog post for details.

    Have a look at perfspy (tutorial), it might already do out of the box what you need.

    Related:

    • How to use AOP with AspectJ for logging?
    • http://mathewjhall.wordpress.com/2011/03/31/tracing-java-method-execution-with-aspectj/
    • http://www.jroller.com/holy/entry/injecting_timing_aspect_into_junit

提交回复
热议问题