How to calculate the time taken by your Program?
Java
Use java.util.Date() or
Use the following simple class StopWatch
to measure time (which uses Date()).
- Call StopWatch.startTimer() when you want to start measuring time .
- Then call StopWatch.currTime() to get the number of milliseconds elapsed
since the call to startTimer().
C/C++ on Un*X (or gcc onWindows)
You can use the function ftime declared in <sys/timeb.h>
or
se the following simple header file stop_watch.h
to measure time
- include the stop_watch.h
- Call startTimer() when you want to start measuring time .
- Then call currTime() to get the number of milliseconds elapsed
since the call to startTimer().
Visual Studio
Similar to the java Code, there is a simple Class StopWatch
provided with the
same interface as above to measure time. .