Cette page appartient aux archives web de l'EPFL et n'est plus tenue à jour.
This page belongs to EPFL's web archive and is no longer updated.

Nicolaus Correll

Measuring elapsed time in C++
#include "time.h"
#include "stdio.h"
#include "windows.h" // you need that on Windows for Sleep()

clock_t start_time,elapsed;

double elapsed_time;


int main(){
start_time = clock();

// Add your code here
Sleep(980);
// end

elapsed = clock()-start_time;

elapsed_time = elapsed / ((double) CLOCKS_PER_SEC);
printf("Time elapsed: %f\n",elapsed_time);

}
Posted by Nicolaus Correll at 16:30