打印时间
2018-02-02 11:29 nigaopeng 阅读(295) 评论(0) 编辑 收藏 举报userspace
#include <sys/time.h> { struct timeval tv_begin, tv_end; gettimeofday(&tv_begin, NULL); //func gettimeofday(&tv_end, NULL); printf("func time %d\n", tv_end.tv_usec - tv_begin.tv_usec); }
kernel
#include <linux/time.h> { struct timeval tx0, tx1; struct timespec c0, c1 do_gettimeofday(&tx0);<br> getrawmonotonic(&c0); //func do_gettimeofday(&tx1); getrawmonotonic(&c1); printk("tx1 - tx0: %ld %ld\n", (tx1.tv_usec - tx0.tv_usec), (c1.tv_nsec - c0.tv_nsec)); }