我们运行程序的时候,可以简单使用clock函数测试程序的运行时间:(本示例中以微秒为单位输出)
https://github.com/yaowenxu/Workplace/blob/master/timer/clocktimer.c
/** * Author: Yaowen Xu * Github: https://github.com/yaowenxu * Organization: 北航系统结构研究所 * Date: 2019-08-18 11:59:54 * LastEditTime: 2019-08-18 12:45:45 * Description: 使用 C 语言标准库函数clock来进行测试程序运行时间 */ #include <time.h> #include <stdio.h> #include <math.h> int str2int(char* str){ char *p = str; int sum = 0; while (*p != '