opencv 3.0 windows 计时函数 timer

来源:互联网 发布:linux search命令 编辑:程序博客网 时间:2024/05/16 11:24

计时函数

1. 纯C 高精度(100ns)测量慢

#include <Windows.h>#include <stdio.h>int timer1_test(){    LARGE_INTEGER start;    LARGE_INTEGER end ;    LARGE_INTEGER frequency;    int i = 0;    if (!QueryPerformanceFrequency(&frequency))    {        return -1;    }    QueryPerformanceCounter(&start); //开始计时//     for (int i = 0; i < 100000; ++i)//     {//         ;// 用循环来测试计时//     }    Sleep(1);    QueryPerformanceCounter(&end); //结束计时    printf("main cost:%f\n", (double)(end.QuadPart - start.QuadPart) / (double)frequency.QuadPart); //打印for循环执行时间    getchar();    return 0;}

2.纯C 低精度(1ms)测量快

#include <stdio.h>#include <time.h>void timer2_test(){ clock_t start,end; start=clock();    Sleep(1000); end=clock(); printf("The differences: %d ms\n",end-start);}


3.C++  OPENCV测试 高精度

 

#include"opencv.hpp"void timer3_test(){    int64 start=0,end=0;    start = getTickCount();    Sleep(1000);    end = getTickCount();    cout << "The differences: " << 1000.0*(end - start)/getTickFrequency()<<" ms"<< endl;}


 

 

 

 

0 0
原创粉丝点击