gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32043 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r32043 - gnunet/src/ats
Date: Mon, 27 Jan 2014 14:47:22 +0100

Author: wachs
Date: 2014-01-27 14:47:22 +0100 (Mon, 27 Jan 2014)
New Revision: 32043

Modified:
   gnunet/src/ats/perf_ats_solver.c
Log:
added multiple iteration support for averaging


Modified: gnunet/src/ats/perf_ats_solver.c
===================================================================
--- gnunet/src/ats/perf_ats_solver.c    2014-01-27 10:51:33 UTC (rev 32042)
+++ gnunet/src/ats/perf_ats_solver.c    2014-01-27 13:47:22 UTC (rev 32043)
@@ -110,10 +110,8 @@
    * */
   struct GNUNET_ATS_PluginEnvironment env;
 
-  struct Result *head;
+  struct Iteration *iterations_results;
 
-  struct Result *tail;
-
   struct Result *current_result;
 
   int current_p;
@@ -160,6 +158,16 @@
   int measure_updates;
 
   /**
+   * Number of iterations
+   */
+  int iterations;
+
+  /**
+   * Current iteration
+   */
+  int current_iteration;
+
+  /**
    * Is a bulk operation running?
    */
   int bulk_running;
@@ -170,6 +178,13 @@
   int expecting_solution;
 };
 
+struct Iteration
+{
+  struct Result *result_head;
+
+  struct Result *result_tail;
+};
+
 struct Result
 {
   struct Result *prev;
@@ -445,8 +460,8 @@
   {
     case GAS_OP_SOLVE_START:
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-          "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
-          (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
+          "Solver notifies `%s' with result `%s' `%s' in iteration %u \n", 
"GAS_OP_SOLVE_START",
+          (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info, 
ph.current_iteration);
       if (GNUNET_NO == ph.expecting_solution)
       {
         /* We do not expect a solution at the moment */
@@ -459,7 +474,8 @@
         /* Create new result */
         tmp = GNUNET_new (struct Result);
         ph.current_result = tmp;
-        GNUNET_CONTAINER_DLL_insert_tail(ph.head, ph.tail, tmp);
+        
GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head,
+            ph.iterations_results[ph.current_iteration-1].result_tail, tmp);
         ph.current_result->addresses = ph.current_a;
         ph.current_result->peers = ph.current_p;
         ph.current_result->s_total = GNUNET_TIME_absolute_get();
@@ -681,9 +697,14 @@
 
 }
 
+/**
+ * Evaluate results for a specific iteration
+ *
+ * @oaram iteration the iteration to evaluate
+ */
 
 static void
-evaluate ()
+evaluate (int iteration)
 {
   struct GNUNET_DISK_FileHandle *f_full;
   struct GNUNET_DISK_FileHandle *f_update;
@@ -754,7 +775,8 @@
     write_gnuplot_script (data_fn_update, GNUNET_NO);
   }
 
-  next = ph.head;
+
+  next = ph.iterations_results[ph.current_iteration -1].result_head;
   while (NULL != (cur = next))
   {
     next = cur->next;
@@ -843,7 +865,8 @@
     GNUNET_free_non_null (str_d_lp);
     GNUNET_free_non_null (str_d_mlp);
 
-    GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur);
+    GNUNET_CONTAINER_DLL_remove 
(ph.iterations_results[ph.current_iteration-1].result_head,
+        ph.iterations_results[ph.current_iteration-1].result_tail, cur);
     GNUNET_free (cur);
   }
 
@@ -860,7 +883,7 @@
 
 
 static void
-perf_run ()
+perf_run (void)
 {
   struct ATS_Address *cur;
   struct ATS_Address *next;
@@ -872,11 +895,10 @@
 
 
   ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
-
   for (cp = 0; cp < count_p; cp++)
     perf_create_peer (cp);
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-      "Added %u peers\n", cp);
+      "Iteration %u of %u, added %u peers\n", ph.current_iteration, 
ph.iterations, cp);
 
   for (cp = 0; cp < count_p; cp++)
   {
@@ -963,8 +985,6 @@
 
   }
   GNUNET_free(ph.peers);
-
-  evaluate ();
 }
 
 
@@ -1039,11 +1059,11 @@
     ph.N_address = DEFAULT_ADDRESSES;
 
   if (ph.N_peers_start != ph.N_peers_end)
-    fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u 
addresses\n",
-        ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
+    fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u 
addresses in %u iterations\n",
+        ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address, 
ph.iterations);
   else
-    fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u 
addresses\n",
-        ph.ats_string, ph.N_peers_end, ph.N_address);
+    fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses 
in %u iterations\n",
+        ph.ats_string, ph.N_peers_end, ph.N_address, ph.iterations);
 
   if (0 == ph.opt_update_percent)
     ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE;
@@ -1064,6 +1084,9 @@
     return;
   }
 
+  /* Create array of DLL to store results for iterations */
+  ph.iterations_results = GNUNET_malloc (sizeof (struct Iteration) * 
ph.iterations);
+
   /* Load solver */
   ph.env.cfg = solver_cfg;
   ph.stat = GNUNET_STATISTICS_create ("ats", cfg);
@@ -1099,8 +1122,12 @@
     return;
   }
 
-  /* Do work */
-  perf_run ();
+  /* Do the benchmark */
+  for (ph.current_iteration = 1; ph.current_iteration <= ph.iterations; 
ph.current_iteration++)
+  {
+    perf_run ();
+    evaluate (ph.current_iteration);
+  }
 
   /* Unload solver*/
   GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), 
ph.ats_string);
@@ -1122,6 +1149,7 @@
   ph.ats_string = NULL;
   ph.create_plot = GNUNET_NO;
   ph.measure_updates = GNUNET_NO;
+  ph.iterations = 1;
 
   static struct GNUNET_GETOPT_CommandLineOption options[] = {
       { 'a', "addresses", NULL,
@@ -1133,6 +1161,9 @@
       { 'e', "end", NULL,
           gettext_noop ("end with peer"),
           1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end },
+      { 'i', "iterations", NULL,
+          gettext_noop ("number of iterations used for averaging (default: 
1)"),
+          1, &GNUNET_GETOPT_set_uint, &ph.iterations },
       { 'p', "percentage", NULL,
           gettext_noop ("update a fix percentage of addresses"),
           1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent },




reply via email to

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