Tuesday, July 28, 2009

How do I know how long a program takes in Java?

I have written a program in Java that is using 2^36 and other large longs and it is taking a long time to compute. Instead of walking away for an hour to come back to it finished, I'd like to know how long it takes... I know there is a way to do that, but forget. Can anyone help me out?

How do I know how long a program takes in Java?
it all depends on your processor speed (according to the information you gave) and the program you are running. Eclipse tends to run slowly. And also depending on what the program is doing, if the program is loading, say several thousand GUIs it may take some time. Also, by what you said about there being longs, the variable long should NOT be used unless you really need it. In java an int is more than a billion and should be fine for most programs, the more memory it takes the slower your program will be. First suggestion would be to take out the longs that arnt neccessary and replace them with ints. Maybe provide some more details. (Java ints are VERY VERY BIG)
Reply:This program shouldn't take a very long time to compute, unless you have a really slow computer.





If it does take long to compute, I'm not sure there is a way to estimate exactly how long it will take.


No comments:

Post a Comment