gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] 01/05: improve command search routine in i


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 01/05: improve command search routine in interpeter, report command execution velocity
Date: Sat, 11 Aug 2018 02:49:11 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

commit f9860f5370d286c2de25b3b93fe92ce39b4fbdf3
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Aug 10 23:16:05 2018 +0200

    improve command search routine in interpeter, report command execution 
velocity
---
 src/exchange-lib/testing_api_loop.c | 40 +++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/exchange-lib/testing_api_loop.c 
b/src/exchange-lib/testing_api_loop.c
index 5538a14..893fc49 100644
--- a/src/exchange-lib/testing_api_loop.c
+++ b/src/exchange-lib/testing_api_loop.c
@@ -49,18 +49,17 @@ TALER_TESTING_interpreter_lookup_command
   (struct TALER_TESTING_Interpreter *is,
    const char *label)
 {
-  const struct TALER_TESTING_Command *cmd;
-
   if (NULL == label)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Attempt to lookup command for empty label\n");
     return NULL;
   }
-  for (unsigned int i=0;
-       NULL != (cmd = &is->commands[i])->label;
-       i++)
+  /* Search backwards as we most likely reference recent commands */
+  for (int i=is->ip; 0 >= i; i--)
   {
+    const struct TALER_TESTING_Command *cmd = &is->commands[i];
+
     /* Give precedence to top-level commands.  */
     if ( (NULL != cmd->label) &&
          (0 == strcmp (cmd->label,
@@ -69,20 +68,20 @@ TALER_TESTING_interpreter_lookup_command
 
     if (GNUNET_YES == cmd->meta)
     {
-      #define BATCH_INDEX 1
+#define BATCH_INDEX 1
       struct TALER_TESTING_Command *batch;
 
-      GNUNET_assert
-        (GNUNET_OK == TALER_TESTING_get_trait_cmd
-          (cmd, BATCH_INDEX, &batch));
-
+      GNUNET_assert (GNUNET_OK ==
+                     TALER_TESTING_get_trait_cmd (cmd,
+                                                  BATCH_INDEX,
+                                                  &batch));
       for (unsigned int i=0;
            NULL != (cmd = &batch[i])->label;
            i++)
       {
         if ( (NULL != cmd->label) &&
-            (0 == strcmp (cmd->label,
-                          label)) )
+             (0 == strcmp (cmd->label,
+                           label)) )
           return cmd;
       }
     }
@@ -169,11 +168,12 @@ interpreter_run (void *cls);
 void
 TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
 {
+  static unsigned long long ipc;
+  static struct GNUNET_TIME_Absolute last_report;
   struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
 
   if (GNUNET_SYSERR == is->result)
     return; /* ignore, we already failed! */
-
   if (GNUNET_YES == cmd->meta)
   {
     #define CURRENT_BATCH_SUBCMD_INDEX 0
@@ -187,8 +187,18 @@ TALER_TESTING_interpreter_next (struct 
TALER_TESTING_Interpreter *is)
   }
   else
     is->ip++;
-
-  is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, is);
+  if (0 == (ipc % 1000))
+  {
+    if (0 != ipc)
+      GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+                  "Interpreter executed 1000 instructions in %s\n",
+                  GNUNET_STRINGS_relative_time_to_string 
(GNUNET_TIME_absolute_get_duration (last_report),
+                                                          GNUNET_YES));
+    last_report = GNUNET_TIME_absolute_get ();
+  }
+  ipc++;
+  is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
+                                       is);
 }
 
 

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



reply via email to

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