diff --git a/.vim/snippets/c.snippets b/.vim/snippets/c.snippets index 89b81ba..258f69b 100644 --- a/.vim/snippets/c.snippets +++ b/.vim/snippets/c.snippets @@ -108,3 +108,12 @@ snippet . [${1}]${2} snippet un unsigned +snippet time_me + { + struct timeval prev_tv, cur_tv, diff_tv; + gettimeofday(&prev_tv, NULL); + ${1:function();} + gettimeofday(&cur_tv, NULL); + timersub(&cur_tv, &prev_tv, &diff_tv); + printf("${2:function} take %d us \n", diff_tv.tv_usec); + }