[PATCH v5 06/11] trace: add current timestamp to all trace output
- From
Karsten Blees <karsten.blees@gmail.com>
- Date
- Jun 11, 2014, 07:59 UTC
- Message-ID
- <53980C6E.9000409@gmail.com>
- In-Reply-To
- <53980B83.9050409@gmail.com>
This is useful to tell apart trace output of separate test runs.
It can also be used for basic, coarse-grained performance analysis. Note that the accuracy is tainted by writing to the trace file, and you have to calculate the deltas yourself (which is next to impossible if multiple threads or processes are involved).
Signed-off-by: Karsten Blees <blees@dcon.de> --- trace.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/trace.c b/trace.c index c920429..5a3393a 100644 --- a/trace.c +++ b/trace.c @@ -79,12 +79,21 @@ static void do_trace_print(const char *key, const struct strbuf *buf) static int prepare_trace_line(const char *key, struct strbuf *buf) { + struct timeval tv; + struct tm tm; + time_t secs; + if (!trace_want(key)) return 0; set_try_to_free_routine(NULL); /* is never reset */ - /* add line prefix here */ + /* print current timestamp */ + gettimeofday(&tv, NULL); + secs = tv.tv_sec; + localtime_r(&secs, &tm); + strbuf_addf(buf, "%02d:%02d:%02d.%06ld ", tm.tm_hour, tm.tm_min, + tm.tm_sec, tv.tv_usec); return 1; }
-- 1.9.2.msysgit.0.501.gaeecf09 -- -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en --- You received this message because you are subscribed to the Google Groups "msysGit" group. To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.