Time Measurement

In Java, you may measure time as follows:

long startTime;
long stopTime;
... startTime = System.currentTimeMillis(); //do whatever you want to measure stopTime = System.currentTimeMillis(); System.out.println("Elapsed time = "+(stopTime-startTime)+" msecs.");

 


In C++, you may measure time as follows:

#include <ctime>
clock_t start,finish;
double time;

start = clock();
sort something
finish = clock();
time = (double(finish)-double(start))/CLOCKS_PER_SEC;

In C, you may measure time as follows:

#include <sys/types.h>
#include <time.h>
time_t t1,t2;
int elapsed_time;

(void) time(&t1);
sort something
(void) time(&t2);
elapsed_time = (int) t2-t1;