gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] 01/02: write exchange stats on exit


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 01/02: write exchange stats on exit
Date: Tue, 02 Oct 2018 17:28:20 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository exchange.

commit 97afbe6364867a6585fe6af701b7bcd097782002
Author: Florian Dold <address@hidden>
AuthorDate: Tue Oct 2 17:21:12 2018 +0200

    write exchange stats on exit
---
 src/exchange/taler-exchange-httpd.c | 49 +++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/exchange/taler-exchange-httpd.c 
b/src/exchange/taler-exchange-httpd.c
index cd6d7793..5fc491a5 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -26,6 +26,7 @@
 #include <jansson.h>
 #include <microhttpd.h>
 #include <pthread.h>
+#include <sys/resource.h>
 #include "taler-exchange-httpd_parsing.h"
 #include "taler-exchange-httpd_mhd.h"
 #include "taler-exchange-httpd_deposit.h"
@@ -845,6 +846,52 @@ open_unix_path (const char *unix_path,
 
 
 /**
+ * Called when the main thread exits, writes out performance
+ * stats if requested.
+ */
+static void
+write_stats ()
+{
+
+  struct GNUNET_DISK_FileHandle *fh;
+  pid_t pid = getpid ();
+  char *benchmark_dir;
+  char *s;
+  struct rusage usage;
+
+  benchmark_dir = getenv ("GNUNET_BENCHMARK_DIR");
+
+  if (NULL == benchmark_dir)
+    return;
+
+  GNUNET_asprintf (&s, "%s/taler-exchange-%llu-%llu.txt",
+                   benchmark_dir,
+                   (unsigned long long) pid);
+
+  fh = GNUNET_DISK_file_open (s,
+                              (GNUNET_DISK_OPEN_WRITE |
+                               GNUNET_DISK_OPEN_TRUNCATE |
+                               GNUNET_DISK_OPEN_CREATE),
+                              (GNUNET_DISK_PERM_USER_READ |
+                               GNUNET_DISK_PERM_USER_WRITE));
+  GNUNET_assert (NULL != fh);
+  GNUNET_free (s);
+
+  /* Collect stats, summed up for all threads */
+  GNUNET_assert (0 == getrusage(RUSAGE_SELF, &usage));
+
+  GNUNET_asprintf (&s, "time_exchange sys %llu user %llu\n", \
+                   (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + 
usage.ru_stime.tv_usec),
+                   (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + 
usage.ru_utime.tv_usec));
+  GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, 
strlen (s)));
+  GNUNET_free (s);
+
+  GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
+}
+
+
+
+/**
  * The main function of the taler-exchange-httpd server ("the exchange").
  *
  * @param argc number of arguments from the command line
@@ -982,6 +1029,8 @@ main (int argc,
     return 1;
   }
 
+  atexit (write_stats);
+
 #if HAVE_DEVELOPER
   if (NULL != input_filename)
   {

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]