取得程序运行时间

    技术2025-05-07  15

    #include <stdio.h>#include <sys/time.h>struct timeval start;struct timeval end;int main(){    int timeuse;    gettimeofday(&start,NULL);    usleep(100);    gettimeofday(&end,NULL);    timeuse = 1000000*(end.tv_sec - start.tv_sec) + end.tv_usec - start.      tv_usec;    printf("timeuse=%d/n",timeuse);    return 0;}

    最新回复(0)