DSP

CCS5.5环境下使用clock()函数测试程序段运行时间

2019-07-13 11:56发布

1、Ctrl+B 编译程序后 F11下载程序 2、Run->Clock->enable 3、F8运行程序 附程序:
#include #include int main(void) { unsigned int a = 10,b = 20,c; clock_t start,stop, overhead,cycles; start = clock(); stop = clock(); overhead = stop - start; start = clock(); //测试代码开始 c = a + b; c++; //测试代码结束 stop = clock(); cycles = stop - start - overhead; printf("cycles: %d ",cycles); printf("times: %.2f us with CPU 456MHz. ",((float) cycles /(float)456)); return 0; }
运行结果: