[vim] add snippet for timing

This commit is contained in:
Mathieu Maret 2012-08-29 13:31:56 +02:00
parent 5fa44eda0a
commit 6c911c38dc

View File

@ -108,3 +108,12 @@ snippet .
[${1}]${2} [${1}]${2}
snippet un snippet un
unsigned 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);
}