This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <iostream> | |
#include <time.h> | |
#include <windows.h> | |
using namespace std; | |
void wait ( int seconds ) | |
{ | |
clock_t endwait; | |
endwait = clock () + seconds * CLOCKS_PER_SEC ; | |
while (clock() < endwait) {} | |
} | |
int main() | |
{ | |
clock_t t1,t2; | |
t1=clock(); | |
int i =0; | |
while(i<10) | |
{ | |
i++; | |
//wait(1); | |
Sleep(1000); | |
cout<<i<<endl; | |
} | |
t2=clock(); | |
long diff = t2-t1; | |
float seconds = (float)diff / CLOCKS_PER_SEC; | |
cout<<"Clock Diffrence:>>"<<diff<<endl;// clock difference | |
cout<<"Time Difference:>>"<<seconds<<endl;// time difference in seconds | |
system ("pause"); | |
return 0; | |
} |
Measure Time in OpenCV
two simple functions to achieve this getTickCount() and getTickFrequency(). The first returns the number of ticks of your systems CPU from a certain event (like since you booted your system). The second returns how many times your CPU emits a tick during a second. So to measure in seconds the number of time elapsed between two operations is easy as:
No comments:
Post a Comment