views:

160

answers:

7

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.

A: 

"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.

Jonathan Feinberg
Ok, thank you very much everyone. I now know where and/or how to begin my search.
Mike
A: 

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

sfussenegger
A: 

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.

Kevin
+1  A: 

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

Chris
+1  A: 
OscarRyz
A: 

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.

Thiru
A: 

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.

n002213f