BachelorWork/appendixes/BC_ZK/demoExamples/timeMeasuring.c

35 lines
1.0 KiB
C
Raw Normal View History

2021-05-27 22:53:37 +00:00
/*
Organization: Technical University of Kosice (TUKE),
Department: Department of Electronics and Multimedia Telecommunications (DEMT/KEMT),
Faculties: Faculty of Electrical Engineering and Informatics (FEI),
Feld of study: Informatics,
Study program: Computer Networks,
School year: 3., Bachelor study, 2020/2021,
Author: Marek Rohac -- MR,
Compiler: Winlibs GCC -- MinGW-W64 x86_64-posix-seh, built by Brecht Sanders, v. 10.2.0,
-- also works with GCC 11.1.0
*/
#include<windows.h>
#include<stdio.h>
#define TIMER_INIT \
LARGE_INTEGER frequency; \
LARGE_INTEGER t1,t2; \
double elapsedTime; \
QueryPerformanceFrequency(&frequency);
// Use to start the performance timer
#define TIMER_START QueryPerformanceCounter(&t1);
// Use to stop the timer
#define TIMER_STOP \
QueryPerformanceCounter(&t2); \
elapsedTime=(double)(t2.QuadPart-t1.QuadPart)/frequency.QuadPart;
int main(){
TIMER_INIT
{TIMER_START
Sleep(1000);
TIMER_STOP}
printf("Time of execution: %f sec\n", elapsedTime);
return 0;
}