gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16268 - gnunet/src/nse


From: gnunet
Subject: [GNUnet-SVN] r16268 - gnunet/src/nse
Date: Mon, 1 Aug 2011 10:09:45 +0200

Author: grothoff
Date: 2011-08-01 10:09:45 +0200 (Mon, 01 Aug 2011)
New Revision: 16268

Modified:
   gnunet/src/nse/nse-profiler.c
Log:
fixes

Modified: gnunet/src/nse/nse-profiler.c
===================================================================
--- gnunet/src/nse/nse-profiler.c       2011-08-01 07:54:55 UTC (rev 16267)
+++ gnunet/src/nse/nse-profiler.c       2011-08-01 08:09:45 UTC (rev 16268)
@@ -42,14 +42,13 @@
   struct GNUNET_NSE_Handle *nse_handle;
 };
 
+
 struct StatsContext
 {
-  GNUNET_SCHEDULER_Task task;
-  GNUNET_SCHEDULER_TaskIdentifier *task_id;
-  void *task_cls;
   unsigned long long total_nse_bytes;
 };
 
+
 static struct NSEPeer *peer_head;
 
 static struct NSEPeer *peer_tail;
@@ -166,6 +165,7 @@
     }
 }
 
+
 static void
 shutdown_task (void *cls,
                const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -193,6 +193,7 @@
   GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
 }
 
+
 /**
  * Callback to call when network size estimate is updated.
  *
@@ -213,11 +214,11 @@
   if (output_file != NULL)
     {
       size = GNUNET_asprintf(&output_buffer, 
-                            "%s %u %llu %f %f %f\n",
+                            "%s %llu %llu %f %f %f\n",
                             GNUNET_i2s(&peer->daemon->id),
                             peers_running,
                             timestamp.abs_value,
-                            pow(2, estimate),
+                            GNUNET_NSE_log_estimate_to_n(estimate),
                             estimate, 
                             std_dev);
       if (size != GNUNET_DISK_file_write(output_file, output_buffer, size))
@@ -234,6 +235,7 @@
 
 }
 
+
 static void
 connect_nse_service (void *cls,
                      const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -281,12 +283,14 @@
 static void 
 stats_finished_callback (void *cls, int success)
 {
-  struct StatsContext *stats_context = (struct StatsContext *)cls;
+  struct StatsContext *stats_context = cls;
   char *buf;
   int buf_len;
 
-  if ((GNUNET_OK == success) && (data_file != NULL)) /* Stats lookup 
successful, write out data */
+  if ( (GNUNET_OK == success) && 
+       (data_file != NULL) )
     {
+      /* Stats lookup successful, write out data */
       buf = NULL;
       buf_len = GNUNET_asprintf(&buf,
                                "TOTAL_NSE_BYTES: %u\n", 
@@ -298,9 +302,8 @@
       GNUNET_free_non_null(buf);
     }
 
-  if (stats_context->task != NULL)
-    *stats_context->task_id = GNUNET_SCHEDULER_add_now(stats_context->task,
-                                                      stats_context->task_cls);
+  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == shutdown_handle);
+  shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
   GNUNET_free(stats_context);
 }
 
@@ -326,44 +329,25 @@
 {
   struct StatsContext *stats_context = cls;
 
-  if ((0 == strstr(subsystem, "nse")) && (0 == strstr(name, "# flood messages 
received")))
-    {
-      stats_context->total_nse_bytes += value;
-    }
-
+  if ( (0 == strstr(subsystem, "nse")) && 
+       (0 == strstr(name, "# flood messages received")) )
+    stats_context->total_nse_bytes += value;
   return GNUNET_OK;
 }
 
 
-/**
- * @param cls struct StatsContext
- * @param tc task context
- */
 static void
-get_statistics (void *cls,
-                const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct StatsContext *stats_context = (struct StatsContext *)cls;
-
-  GNUNET_TESTING_get_statistics(pg, 
-                               &stats_finished_callback, 
-                               &statistics_iterator, 
-                               stats_context);
-}
-
-
-static void
 disconnect_nse_peers (void *cls,
                       const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct NSEPeer *pos;
   char *buf;
   struct StatsContext *stats_context;
-  disconnect_task = GNUNET_SCHEDULER_NO_TASK;
-  pos = peer_head;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "disconnecting nse service of peers\n");
+  disconnect_task = GNUNET_SCHEDULER_NO_TASK;
+  pos = peer_head;
   while (NULL != (pos = peer_head))
     {
       if (pos->nse_handle != NULL)
@@ -392,19 +376,17 @@
       stats_context = GNUNET_malloc(sizeof(struct StatsContext));
       GNUNET_SCHEDULER_cancel(shutdown_handle);
       shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
-      stats_context->task = &shutdown_task;
-      stats_context->task_cls = NULL;
-      stats_context->task_id = &shutdown_handle;
-      GNUNET_SCHEDULER_add_now(&get_statistics, stats_context);
-      //shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
+      GNUNET_TESTING_get_statistics(pg, 
+                                   &stats_finished_callback, 
+                                   &statistics_iterator, 
+                                   stats_context);
     }
   GNUNET_free(buf);
 }
 
 
 /**
- * Prototype of a function that will be called when a
- * particular operation was completed the testing library.
+ * FIXME.
  *
  * @param cls unused
  * @param emsg NULL on success
@@ -412,17 +394,14 @@
 static void 
 topology_output_callback (void *cls, const char *emsg)
 {
-  struct StatsContext *stats_context;
-  stats_context = GNUNET_malloc(sizeof(struct StatsContext));
-
-  disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, 
&disconnect_nse_peers, NULL);
+  disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, 
+                                                &disconnect_nse_peers, NULL);
   GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL);
 }
 
 
 /**
- * Prototype of a function that will be called when a
- * particular operation was completed the testing library.
+ * FIXME.
  *
  * @param cls closure
  * @param emsg NULL on success
@@ -436,11 +415,11 @@
     {
       peers_running = peers_next_round;
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Round %lu, churn finished successfully.\n",
+                  "Round %llu, churn finished successfully.\n",
                  current_round);
       GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK);
       GNUNET_asprintf(&temp_output_file, 
-                     "%s_%lu.dot",
+                     "%s_%llu.dot",
                      topology_file, 
                      current_round);
       GNUNET_TESTING_peergroup_topology_to_file(pg,
@@ -455,10 +434,10 @@
   else
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Round %lu, churn FAILED!!\n",
+                  "Round %llu, churn FAILED!!\n",
                  current_round);
       GNUNET_SCHEDULER_cancel(shutdown_handle);
-      GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
+      shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
     }
 }
 
@@ -490,20 +469,23 @@
           GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
         }
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Round %lu, turning off %lu peers, turning on %lu peers!\n",
+                  "Round %llu, turning off %llu peers, turning on %llu 
peers!\n",
                   current_round,
-                  (peers_running > peers_next_round) ? peers_running
-                      - peers_next_round : 0,
-                  (peers_next_round > peers_running) ? peers_next_round
-                      - peers_running : 0);
+                  (peers_running > peers_next_round) 
+                 ? peers_running - peers_next_round 
+                 : 0,
+                  (peers_next_round > peers_running) 
+                 ? peers_next_round - peers_running 
+                 : 0);
       GNUNET_TESTING_daemons_churn (pg, "nse",
-                                    (peers_running > peers_next_round) ? 
peers_running
-                                        - peers_next_round
-                                        : 0,
-                                    (peers_next_round > peers_running) ? 
peers_next_round
-                                        - peers_running
-                                        : 0, wait_time, &churn_callback,
-                                    NULL);
+                                    (peers_running > peers_next_round) 
+                                   ? peers_running - peers_next_round
+                                   : 0,
+                                    (peers_next_round > peers_running) 
+                                   ? peers_next_round - peers_running
+                                   : 0, 
+                                   wait_time,
+                                   &churn_callback, NULL);
     }
 }
 
@@ -515,6 +497,7 @@
   disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, 
&disconnect_nse_peers, NULL);
 }
 
+
 static void
 my_cb (void *cls,
        const char *emsg)
@@ -535,7 +518,8 @@
               "Peer Group started successfully, connecting to NSE service for 
each peer!\n");
 #endif
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-             "Have %u connections\n", total_connections);
+             "Have %u connections\n",
+             total_connections);
   if (data_file != NULL)
     {
       buf = NULL;
@@ -555,6 +539,7 @@
 
 }
 
+
 /**
  * Function that will be called whenever two daemons are connected by
  * the testing library.
@@ -596,12 +581,12 @@
 
   ok = 1;
   testing_cfg = GNUNET_CONFIGURATION_create();
-  GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_load(testing_cfg, cfgfile));
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
-  GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
-                                           "use_progressbars",
-                                           "YES");
+  GNUNET_CONFIGURATION_set_value_string (testing_cfg,
+                                        "testing",
+                                        "use_progressbars",
+                                        "YES");
 #endif
   if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, 
                                                          "testing",
@@ -716,8 +701,6 @@
 int
 main (int argc, char *argv[])
 {
-  int ret;
-
   GNUNET_log_setup ("nse-profiler",
 #if VERBOSE
                     "DEBUG",
@@ -725,15 +708,15 @@
                     "WARNING",
 #endif
                     NULL);
-  ret = 1;
   GNUNET_PROGRAM_run (argc,
-                      argv, "nse-profiler", gettext_noop
-                      ("Run a test of the NSE service."),
-                      options, &run, &ok);
+                      argv, "nse-profiler", 
+                     gettext_noop ("Measure quality and performance of the NSE 
service."),
+                      options, 
+                     &run, NULL);
 #if REMOVE_DIR
   GNUNET_DISK_directory_remove ("/tmp/nse-profiler");
 #endif
-  return ret;
+  return ok;
 }
 
 /* end of nse-profiler.c */




reply via email to

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