From: José Fonseca Date: Wed, 29 Jul 2009 11:39:55 +0000 (+0100) Subject: Time call durations. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=b450899a5ce4494ec395340496a6f317e640f99c;p=apitrace Time call durations. --- diff --git a/log.cpp b/log.cpp index 97f2271..433368f 100644 --- a/log.cpp +++ b/log.cpp @@ -228,14 +228,34 @@ void TextF(const char *format, ...) { Text(szBuffer); } +static LARGE_INTEGER frequency = {0}; +static LARGE_INTEGER startcounter; + void BeginCall(const char *function) { EnterCriticalSection(&CriticalSection); Indent(1); BeginTag("call", "name", function); NewLine(); + + if(!frequency.QuadPart) + QueryPerformanceFrequency(&frequency); + + QueryPerformanceCounter(&startcounter); } void EndCall(void) { + LARGE_INTEGER endcounter; + LONGLONG usecs; + + QueryPerformanceCounter(&endcounter); + usecs = (endcounter.QuadPart - startcounter.QuadPart)*1000000/frequency.QuadPart; + + Indent(2); + BeginTag("duration"); + TextF("%llu", usecs); + EndTag("duration"); + NewLine(); + Indent(1); EndTag("call"); NewLine();