diff options
author | Brian Paul <[email protected]> | 2013-01-30 15:45:08 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-02-01 08:00:28 -0700 |
commit | 9a91ce94484789424361f22387ba15688d6bcc7d (patch) | |
tree | 45a00aef1277dd021ff729c896831be08af0054d /src/gallium/drivers/trace/tr_dump.c | |
parent | b516bf46ef7869a3cbf3fff85c77a25d4c882133 (diff) |
trace: measure time for each gallium call
To get a rough idea of how much time is spent in each gallium driver
function. The time is measured in microseconds.
Diffstat (limited to 'src/gallium/drivers/trace/tr_dump.c')
-rw-r--r-- | src/gallium/drivers/trace/tr_dump.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index cd106af9cda..48c8914f7bb 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -45,6 +45,7 @@ #include "pipe/p_compiler.h" #include "os/os_thread.h" +#include "os/os_time.h" #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_string.h" @@ -234,6 +235,20 @@ trace_dump_trace_close(void) } } + +static void +trace_dump_call_time(int64_t time) +{ + if (stream) { + trace_dump_indent(2); + trace_dump_tag_begin("time"); + trace_dump_int(time); + trace_dump_tag_end("time"); + trace_dump_newline(); + } +} + + boolean trace_dump_trace_begin(void) { @@ -345,6 +360,8 @@ boolean trace_dumping_enabled(void) * Dump functions */ +static int64_t call_start_time = 0; + void trace_dump_call_begin_locked(const char *klass, const char *method) { if (!dumping) @@ -360,13 +377,20 @@ void trace_dump_call_begin_locked(const char *klass, const char *method) trace_dump_escape(method); trace_dump_writes("\'>"); trace_dump_newline(); + + call_start_time = os_time_get(); } void trace_dump_call_end_locked(void) { + int64_t call_end_time; + if (!dumping) return; + call_end_time = os_time_get(); + + trace_dump_call_time(call_end_time - call_start_time); trace_dump_indent(1); trace_dump_tag_end("call"); trace_dump_newline(); |