首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >计算我的程序的执行时间

计算我的程序的执行时间
EN

Stack Overflow用户
提问于 2013-07-19 13:29:15
回答 2查看 121关注 0票数 0

因此,在我的图像处理项目中,我目前使用gettickcount()来计算处理每一帧所需的平均时间。但是,为了提高速度,我选择了每隔一帧处理一次。从理论上讲,程序应该运行得更快,事实也的确如此。但是,我从gettickcount获得的值保持不变。这让我相信gettickcount函数仍然在计算程序的未处理图像的节拍。

代码语言:javascript
复制
while(capture.grab())
{
    int64 t = getTickCount();

    if(count == 0) //count is each image number. this segment processes the first image
    {

    }

    if(count % 2 == 1) //processes every other image
    {

    }
}

即使没有使用getTickCount函数,它是否仍然计算if(count %2 == 1)中的刻度数?

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-23 02:14:12

代码语言:javascript
复制
#include<stdio.h>
#include<time.h>

int main()
{

clock_t start = clock();

//write your code here, and this will calculate the execution time of the code...

clock_t ends = clock();

printf("run time: %.5f \n", ((double)(ends - 

start)) / CLOCKS_PER_SEC);

return 0;

}
票数 0
EN

Stack Overflow用户

发布于 2013-07-19 13:36:21

是。不管"count“的值是什么,在while循环的每一次传递中都会调用getTickCount。

尝试:

代码语言:javascript
复制
while(capture.grab())
{
    int64 t = 0;

    if(count == 0) //count is each image number. this segment processes the first image
    {
      t = getTickCount();
    }
    if(count % 2 == 1) //processes every other image
    {
      t = getTickCount();
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17738718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档