8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
[C语言] 如何计算某一段程序执行时间
在Unix-like中,我们可以用 time [option] command 这种方法来计算出command执行所花费的时间,不过若是该command是一个daemon process, 我们一般来说 都只会监看log,此时若要知道某一段程序执行花费了多少时间, 当然我们可以用gettimeofday以及localtime_r来取得详细的日期与时间来进行相减的动作, 不过若是单纯只想计算时间,这边提供clock function来做更加的方便, 下方是使用的Sample Code
#include #include /* This sample will display how to calculate the program execution time */
int plus(int iEnd)
{
int i = 0;
while(i < iEnd)
i++;
return i;
}
int main(int argc, char *argv[])
{
clock_t start_time, end_time;
float total_time = 0;
int iNum = 0;
if (argc < 2)
{
printf("Usage : %s Numn", argv[0]);
return -1;
}
start_time = clock(); /* mircosecond */
iNum = plus(atoi(argv[1]));
end_time = clock();
/* CLOCKS_PER_SEC is defined at time.h */
total_time = (float)(end_time - start_time)/CLOCKS_PER_SEC;
printf("Time : %f sec n", total_time);
return 0;
}
===========================这是签名档分隔线==============================
我没有什么技术能力
不过却希望在这边跟大家分享自己遭遇的一些问题
希望大家有更好的方法可以跟我说!!======================================================================