From b450899a5ce4494ec395340496a6f317e640f99c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 29 Jul 2009 12:39:55 +0100 Subject: [PATCH] Time call durations. --- log.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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(); -- 2.45.2