From 6c911c38dc5ed0e82d25702498eb56d074fc418b Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Wed, 29 Aug 2012 13:31:56 +0200 Subject: [PATCH] [vim] add snippet for timing --- .vim/snippets/c.snippets | 9 +++++++++ 1 file changed, 9 insertions(+) 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); + }