linux c 编程 ------ 获取时间,计算程序执行时间

 

#include <time.h>
#include <stdio.h>
#include <unistd.h>


int main(int argc, char argv[])
{
    time_t t;
    
    time(&t);
    printf(" second is %ld\n",t);
    
    sleep(1);
    
    t = time(NULL);
    printf(" second is %ld\n",t);

    return 0;
}

 

posted @ 2018-04-04 18:47  流水灯  阅读(2741)  评论(0编辑  收藏  举报