struct timeval用法 ,计算程序运行时间

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

int  main()
{
    struct timeval t_start, t_end;

    gettimeofday(&t_start,NULL);

    printf("hello world\n");

    gettimeofday(&t_end,NULL);

    printf("cost time %ldus\n", t_end.tv_usec - t_start.tv_usec);

    return 0;

}

link

posted @ 2022-08-19 22:46  luoganttcc  阅读(75)  评论(0)    收藏  举报