[gimp/bug-626494] Bug 626494 - Enhancement to script-fu-server logging to output milliseconds taken



commit 5392bef49449cc2b1cf123f27e4fc72008344f71
Author: Cameron Gregory <public bloke com>
Date:   Sat Jun 25 20:52:27 2016 +0200

    Bug 626494 - Enhancement to script-fu-server logging to output milliseconds taken

 plug-ins/script-fu/script-fu-server.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/plug-ins/script-fu/script-fu-server.c b/plug-ins/script-fu/script-fu-server.c
index 2b6e7ed..5d0bb21 100644
--- a/plug-ins/script-fu/script-fu-server.c
+++ b/plug-ins/script-fu/script-fu-server.c
@@ -547,15 +547,16 @@ server_start (const gchar *listen_ip,
 static gboolean
 execute_command (SFCommand *cmd)
 {
-  guchar    buffer[RESPONSE_HEADER];
-  GString  *response;
-  time_t    clock1;
-  time_t    clock2;
-  gboolean  error;
-  gint      i;
+  guchar      buffer[RESPONSE_HEADER];
+  GString    *response;
+  time_t      clocknow;
+  gboolean    error;
+  gint        i;
+  gdouble     total_time;
+  GTimer      *timer;
 
   server_log ("Processing request #%d\n", cmd->request_no);
-  time (&clock1);
+  timer = g_timer_new ();
 
   response = g_string_new (NULL);
   ts_register_output_func (ts_gstring_output_func, response);
@@ -574,10 +575,12 @@ execute_command (SFCommand *cmd)
       if (response->len == 0)
         g_string_assign (response, ts_get_success_msg ());
 
-      time (&clock2);
-      server_log ("Request #%d processed in %f seconds, finishing on %s",
-                  cmd->request_no, difftime (clock2, clock1), ctime (&clock2));
+      total_time = g_timer_elapsed (timer, NULL);
+      time (&clocknow);
+      server_log ("Request #%d processed in %.3f seconds, finishing on %s",
+                  cmd->request_no, total_time, ctime (&clocknow));
     }
+  g_timer_destroy (timer);
 
   buffer[MAGIC_BYTE]     = MAGIC;
   buffer[ERROR_BYTE]     = error ? TRUE : FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]