I have seen the below plugin being used however i'm told it has been discontinued:
Thank you in advance for any time taken to help.
At the first line of your main method add:
Then at the last line of the main method add;
For those who prefer a time in milliseconds (including myself) I changed the code that goes on the last line of your main method to this to this;
Campbell Ritchie wrote:There is no such thing as an Eclipse program, only Java® programs. If you mean you want to get Eclipse to time from starting to run the program until the JVM exits, try looking at this SO thread. It mentions the TPTP project which has been archived, and probably not removed. It also says you can add time to a run configuration, but I couldn't work out where. It didn't run correctly when I tried it.
Thank you for your corrections, noted. I meant to say a Java program written within Eclipse, but yes what you then mentioned is what i was looking for. Thanks.
Use integer arithmetic rather than doubles. I would prefer a slightly more complicated algorithm that that suggested by the System class documentation:-That allows you to estimate and eliminate the time for a nanoTime() call, but that might be an insignificant duration if foo() takes a long time. If you prefer milliseconds, don't divide by 1000000, but use this instead. A millisecond timing will be very inaccurate if foo() takes a short time to complete.
Harry Orson wrote:. . . System.nanoTime();
. . .
milliseconds = duration / 1000000.0 . . .
That is of course a completely different timing from how long it takes Eclipse to run your application.
That's the same as
Which takes the obvious calculation (after - start) and subtracts off the time to execute System.nanoTime().
But for me if you're running something for which the time to execute System.nanoTime() isn't a negligible quantity, then you're ignoring all of the problems which arise when you do a micro-benchmark in Java. So I wouldn't bother with that myself.
My technique does require quite a lot of assumptions like that.
Junilu Lacar wrote:. . . Assuming the call to nano() costs the same # of ns every time . . .
Try this sort of code several times:-. . . and the nanoTime call seems similar in duration every time, and about 0.001 of the println() call, so it reduces the time from 100% to 99.9%