cuda中计时程序 cutCreatTimer& clock


#include "time.h"   


clock_t t_start,t_stop;

   double time_spend;


   t_start=clock();

 // the operations you want do 

... ...

... ...


  t_stop=clock();

   time_spend=(double)(t_stop-t_start)/CLOCKS_PER_SEC;

printf("the time spend is %d s\n", time_spend);


timer on cuda

以下是在cuda sdk例子中找到的相关计时程序,测试过可以用,但是关于shrQAStart我还没有大概明白是肿么回事,先拿来备份一下,以备之后忘了。其中win32调试需要加入cutil32D.lib;shrUtils32D.lib两个库,x64调试需要加入cutil64D.lib;shrUtils64D.lib

#include <cutil_inline.h>
#include <shrQATest.h>

main(int argc, char** argv)

{

shrQAStart(argc, argv);

// start the timer

unsigned int timer = 0;
cutilCheckError( cutCreateTimer( &timer));
cutilCheckError( cutStartTimer( timer));

// operations 


....

...

...

//*stop & delete a time clock
cutilCheckError( cutStopTimer( timer));
printf( "Processing time(cutTimer): %f (ms)\n", cutGetTimerValue( timer));
cutilCheckError( cutDeleteTimer( timer));


shrQAFinishExit(argc, (const char **)argv, 1 );

}


Ps:用clock和timer得到的时间不是很一样,期待找到两者的区别~~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值