gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r38244 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r38244 - gnunet/src/cadet
Date: Fri, 4 Nov 2016 10:47:22 +0100

Author: bartpolot
Date: 2016-11-04 10:47:22 +0100 (Fri, 04 Nov 2016)
New Revision: 38244

Modified:
   gnunet/src/cadet/cadet.h
   gnunet/src/cadet/gnunet-service-cadet_tunnel.c
Log:
- refactor function timing code

Modified: gnunet/src/cadet/cadet.h
===================================================================
--- gnunet/src/cadet/cadet.h    2016-11-04 09:47:21 UTC (rev 38243)
+++ gnunet/src/cadet/cadet.h    2016-11-04 09:47:22 UTC (rev 38244)
@@ -36,8 +36,23 @@
 
 #include <stdint.h>
 
-#define CADET_DEBUG              GNUNET_YES
+#if !defined(GNUNET_CULL_LOGGING)
+  #define CADET_TIMING_START \
+          struct GNUNET_TIME_Absolute __timestamp;\
+          __timestamp = GNUNET_TIME_absolute_get()
 
+  #define CADET_TIMING_END   \
+          struct GNUNET_TIME_Relative __duration;\
+          __duration = GNUNET_TIME_absolute_get_duration (__timestamp);\
+          LOG (GNUNET_ERROR_TYPE_INFO, " %s duration %s\n",\
+              __FUNCTION__,\
+              GNUNET_STRINGS_relative_time_to_string (__duration, GNUNET_YES));
+#else
+  #define CADET_TIMING_START
+  #define CADET_TIMING_END
+#endif
+
+
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_peer_lib.h"

Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2016-11-04 09:47:21 UTC 
(rev 38243)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2016-11-04 09:47:22 UTC 
(rev 38244)
@@ -38,9 +38,9 @@
 #define REKEY_WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
 
 #if !defined(GNUNET_CULL_LOGGING)
-#define DUMP_KEYS_TO_STDERR GNUNET_YES
+  #define DUMP_KEYS_TO_STDERR GNUNET_YES
 #else
-#define DUMP_KEYS_TO_STDERR GNUNET_YES
+  #define DUMP_KEYS_TO_STDERR GNUNET_NO
 #endif
 
 #define MIN_TUNNEL_BUFFER       8
@@ -50,7 +50,6 @@
 #define AX_HEADER_SIZE (sizeof (uint32_t) * 2\
                         + sizeof (struct GNUNET_CRYPTO_EcdhePublicKey))
 
-
 
/******************************************************************************/
 /********************************   STRUCTS  
**********************************/
 
/******************************************************************************/
@@ -732,14 +731,11 @@
   struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
   struct CadetTunnelAxolotl *ax;
   size_t out_size;
-  struct GNUNET_TIME_Absolute start_time;
-  struct GNUNET_TIME_Relative duration;
 
+  CADET_TIMING_START;
+
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  t_ax_encrypt start\n");
-  start_time = GNUNET_TIME_absolute_get ();
-
   ax = t->ax;
-
   ax->ratchet_counter++;
   if (GNUNET_YES == ax->ratchet_allowed
       && (ratchet_messages <= ax->ratchet_counter
@@ -788,13 +784,9 @@
   #endif
 
   out_size = GNUNET_CRYPTO_symmetric_encrypt (src, size, &MK, &iv, dst);
-
   t_hmac_derive_key (&ax->CKs, &ax->CKs, "1", 1);
 
-  duration = GNUNET_TIME_absolute_get_duration (start_time);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  t_ax_encrypt duration %s\n",
-       GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  t_ax_encrypt end\n");
+  CADET_TIMING_END;
 
   return out_size;
 }
@@ -2010,6 +2002,8 @@
   const struct GNUNET_PeerIdentity *pid;
   int am_I_alice;
 
+  CADET_TIMING_START;
+
   LOG (GNUNET_ERROR_TYPE_INFO, "<== {        KX} on %s\n", GCT_2s (t));
 
   if (NULL == t->ax)
@@ -2130,8 +2124,11 @@
   ax->PNs = 0;
   ax->Nr = 0;
   ax->Ns = 0;
+
   GCT_change_estate (t, CADET_TUNNEL_KEY_PING);
   send_queued_data (t);
+
+  CADET_TIMING_END;
 }
 
 /**




reply via email to

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