opencv 3.0 windows 计时函数 timer

计时函数

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值