0 votes
340 views
in Java by
I wrote a program and now I want to calculate the total running time of my program from start to end. How to calculate the running time of my program?

1 Answer

0 votes
by (5k points)
To calculate program running time by using System.currentTimeMillis() or System.nanoTime().

See the running code for calculating program running time:-

long start = System.currentTimeMillis();
-------------------
Your program code
-------------------
long end = System.currentTimeMillis();
NumberFormat formatter = new DecimalFormat("#0.00000");
System.out.print("Execution time: " + formatter.format((end - start) / 1000d) + " (seconds)");

Now, you can get time in seconds.

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...