Computer Science Canada Is it possible to calulate execution time? |
Author: | supahsain08 [ Mon May 26, 2008 9:52 am ] |
Post subject: | Is it possible to calulate execution time? |
Hello, is it possible to calculate the time it took the program to execute Thanks btw i am using Jcreator IDE |
Author: | Tony [ Mon May 26, 2008 11:04 am ] |
Post subject: | RE:Is it possible to calulate execution time? |
The term is benchmark(ing) There are usually fancy libraries available for that, but the bottom line is that you simply need to record the current time in a variable, run whatever, record the current time afterwards, and take the difference. |
Author: | rizzix [ Mon May 26, 2008 11:05 am ] | ||
Post subject: | RE:Is it possible to calulate execution time? | ||
Hmm, well depending on whether you want to calculate the startup time as well you'd have to do this in two different ways. If you don't care about the jvm startup time, you can make use of the System.currentTimeMillis(); or System.nanoTime(); methods. Use them at the beginning and end of your main() method. Something like this:
Edit: Ah, Tony beat be to it. |
Author: | supahsain08 [ Thu May 29, 2008 5:58 pm ] |
Post subject: | RE:Is it possible to calulate execution time? |
Thanks |