
Фрагмент кода для расчета времени, прошедшего между двумя событиями (к примеру, чтобы выяснить, сколько времени займет выполнение чего-либо).
#include "stdafx.h"
#include <time.h>
#include <windows.h>
#include <stdlib.h>
clock_t startm, stopm;
#define BEGIN if ( (startm = clock()) == -1) \
{ \
printf("clock returned error.");exit(1); \
} \
#define CLOSE if ( (stopm = clock()) == -1) \
{printf("clock returned error."); \
exit(1); \
} \
#define SHOWTIME printf( "%6.3f seconds elapsed.", ((double)stopm-startm)/CLOCKS_PER_SEC);
main() {
BEGIN;
// Specify set of instructions for you want to measure execution time
Sleep(10);
CLOSE;
SHOWTIME;
}