简体   繁体   中英

Java Program Performance (running time & memory consumption)

Which tools can I use to know the life-time or run-time of a program(from the beginning until the program ends)? I also want to know how much memory that program consumes from start to end. The program is written in Java and I'm running it on Windows XP.

You could use JConsole, here's an article describing it's usage

替代文字

If you were using *nix you could use the 'time' command. For Windows see this other SO thread

Have you checked Dynatrace ? Commercial one but pretty useful for what you are looking for. Have been using it and found very useful to trace down execution path, time spent on each apis etc.

"How much time" a program takes is a tricky question, and the answer varies tremendously depending on the state of OS disk caches, and whether you include the start-up time of the JVM itself, etc.

The other part of your question is much easier to answer: you need a profiler . A profiler will not only tell you gross memory statistics (or gross runtime), but will allow you to pinpoint the trouble spots in your programs, areas that create an inordinate number of objects per unit time, or places that burn a lot of CPU relative to other places in your code.

If you're interested in monitoring, you may use jconsole which is part of the JDK. Otherwise, please elaborate on your question.

You can try monitoring your application with the jconsole tool that ships with the JDK now. If that isn't enough, I'd try profiling your application with something like YourKit . Its a commercial product but extremely useful.

I understand that NetBeans has a profiler built in but I have not used it. If you're using NetBeans, that might be an option as well.

I use VisualVM from Sun, and its very good, with lots of useful features . You can monitor Heap Space usage, Loaded Classes, GC Activity and Live Threads.

You can also do the same for remote Java applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM