signed push: teach smart-HTTP to pass "git push --signed" around
[gitweb.git] / trace.c
diff --git a/trace.c b/trace.c
index af64dbbcf319d8bc6b21b9b2ac6b75dbc4c6f5a3..e583dc63bb8d7062f8b735e701978574e9fcbf25 100644 (file)
--- a/trace.c
+++ b/trace.c
@@ -404,3 +404,25 @@ inline uint64_t getnanotime(void)
                return now;
        }
 }
+
+static uint64_t command_start_time;
+static struct strbuf command_line = STRBUF_INIT;
+
+static void print_command_performance_atexit(void)
+{
+       trace_performance_since(command_start_time, "git command:%s",
+                               command_line.buf);
+}
+
+void trace_command_performance(const char **argv)
+{
+       if (!trace_want(&trace_perf_key))
+               return;
+
+       if (!command_start_time)
+               atexit(print_command_performance_atexit);
+
+       strbuf_reset(&command_line);
+       sq_quote_argv(&command_line, argv, 0);
+       command_start_time = getnanotime();
+}