gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14990 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r14990 - gnunet/src/transport
Date: Fri, 15 Apr 2011 13:47:58 +0200

Author: wachs
Date: 2011-04-15 13:47:58 +0200 (Fri, 15 Apr 2011)
New Revision: 14990

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/test_transport_ats.c
Log:
improvements for better benchmarking


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-04-15 11:36:35 UTC 
(rev 14989)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-04-15 11:47:58 UTC 
(rev 14990)
@@ -6062,23 +6062,6 @@
        /* done */
        }
 
-       if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1))
-       {
-               char * filename;
-               GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",c_peers, 
c_mechs, GNUNET_TIME_absolute_get().abs_value);
-               //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
-                       glp_write_lp (prob, NULL, filename);
-               GNUNET_free (filename);
-       }
-       if ((ats->save_solution == GNUNET_YES) && (c_peers > 1))
-       {
-               char * filename;
-               GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol",c_peers, 
c_mechs, GNUNET_TIME_absolute_get().abs_value);
-               //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
-                       glp_print_sol (prob, filename);
-               GNUNET_free (filename);
-       }
-
        /*
        int check;
        int error = GNUNET_NO;
@@ -6774,6 +6757,7 @@
        struct GNUNET_TIME_Absolute start;
        struct GNUNET_TIME_Relative creation;
        struct GNUNET_TIME_Relative solving;
+       char *text = "unmodified";
 
        struct GNUNET_TIME_Relative delta = 
GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get());
        if (delta.rel_value < ats->min_delta.rel_value)
@@ -6793,19 +6777,22 @@
        start = GNUNET_TIME_absolute_get();
        if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL))
        {
+               text = "new";
                ats_delete_problem ();
                ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, 
ats->v_n_min, &ats->stat);
 #if DEBUG_ATS
                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were 
modified... new problem: %i peer, %i mechs\n", ats->stat.c_peers, 
ats->stat.c_mechs);
 #endif
        }
-       else if (ats->modified_resources == GNUNET_YES)
+       else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_resources 
== GNUNET_YES))
        {
                ats_update_problem_cr();
+               text = "modified resources";
        }
-       else if (ats->modified_quality == GNUNET_YES)
+       else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_quality == 
GNUNET_YES))
        {
                ats_update_problem_qm();
+               text = "modified quality";
        }
 #if DEBUG_ATS
        else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n");
@@ -6818,8 +6805,8 @@
        {
                ats->stat.solution = GNUNET_SYSERR;
                ats_solve_problem(ats->max_iterations, 
ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, 
&ats->stat);
-               if (ats->stat.solution != 5)
-                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solution 
is not optimal: %i\n", ats->stat.solution);
+               //if (ats->stat.solution != 5)
+                       //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem 
solution is not optimal: %i\n", ats->stat.solution);
        }
 
        solving = 
GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
@@ -6827,7 +6814,11 @@
        if (ats->stat.valid == GNUNET_YES)
        {
 #if DEBUG_ATS
-                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP: creation 
time in [ms] %llu execution time in [ms] %llu for %i mechanisms\n", 
creation.rel_value, solving.rel_value, ats->stat.c_mechs);
+
+               //if (ats->stat.c_peers > 1)
+               //{
+                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP %s: creation 
time in [ms] %llu execution time in [ms] %llu for %i mechanisms\n", text, 
creation.rel_value, solving.rel_value, ats->stat.c_mechs);
+               //}
 #endif
                GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value 
+ creation.rel_value, GNUNET_NO);
                GNUNET_STATISTICS_set (stats, "ATS mechanisms", 
ats->stat.c_mechs, GNUNET_NO);
@@ -6852,6 +6843,24 @@
                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no 
addresses\n");
        }
 #endif
+
+       if ((ats->save_mlp == GNUNET_YES) && (ats->stat.c_peers > 1))
+       {
+               char * filename;
+               GNUNET_asprintf (&filename, 
"ats_mlp_p%i_m%i_%llu.mlp",ats->stat.c_peers, ats->stat.c_mechs, 
GNUNET_TIME_absolute_get().abs_value);
+               //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
+                       glp_write_lp (ats->prob, NULL, filename);
+               GNUNET_free (filename);
+       }
+       if ((ats->save_solution == GNUNET_YES) && (ats->stat.c_peers > 1))
+       {
+               char * filename;
+               GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol", 
ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value);
+               //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
+                       glp_print_sol (ats->prob, filename);
+               GNUNET_free (filename);
+       }
+
        ats->last = GNUNET_TIME_absolute_get();
 
        ats->modified_addr = GNUNET_NO;

Modified: gnunet/src/transport/test_transport_ats.c
===================================================================
--- gnunet/src/transport/test_transport_ats.c   2011-04-15 11:36:35 UTC (rev 
14989)
+++ gnunet/src/transport/test_transport_ats.c   2011-04-15 11:47:58 UTC (rev 
14990)
@@ -49,6 +49,7 @@
 static int failed_peers;
 
 static int measurement_started = GNUNET_NO;
+static char * config_file;
 
 static struct GNUNET_TESTING_PeerGroup *pg;
 
@@ -87,6 +88,7 @@
 static int force_q_updates;
 static int force_rebuild;
 static int send_msg;
+static int machine_parsable;
 
 static struct TEST_result results_new       [MEASUREMENTS+1];
 static struct TEST_result results_modified  [MEASUREMENTS+1];
@@ -198,62 +200,74 @@
 static void evaluate_measurements()
 {
        int c;
-       double average ;
-       double stddev;
-
+       //int mechs = 0;
+       double average[3];
+       double stddev[3];
+       //char * output;
        c = 1;
 
-       average = 0.0;
+       //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, 
results_modified[0].mechs,
+
+       average[0] = 0.0;
        for (c=0; c<c_new;c++)
        {
-               average += (double) results_new[c].duration;
+               average[0] += (double) results_new[c].duration;
        }
-       average /= c_new;
+       average[0] /= c_new;
 
-       stddev = 0.0;
+       stddev[0] = 0.0;
        for (c=0; c<c_new;c++)
        {
-               stddev += (results_new[c].duration - average) * 
(results_new[c].duration - average);
+               stddev[0] += (results_new[c].duration - average[0]) * 
(results_new[c].duration - average[0]);
        }
-       stddev /= c_new;
-       stddev = sqrt (stddev);
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new average: %f stddev: %f\n", 
average, stddev);
+       stddev[0] /= c_new;
+       stddev[0] = sqrt (stddev[0]);
+       if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new, %i 
measurements, average: %f stddev: %f\n",
+                       c_new, average[0], stddev[0]);
 
-       average = 0.0;
+       average[1] = 0.0;
        for (c=0; c<c_modified;c++)
        {
-               average += (double) results_modified[c].duration;
+               average[1] += (double) results_modified[c].duration;
        }
-       average /= c_modified;
+       average[1] /= c_modified;
 
-       stddev = 0.0;
+       stddev[1] = 0.0;
        for (c=0; c<c_modified;c++)
        {
-               stddev += (results_modified[c].duration - average) * 
(results_modified[c].duration - average);
+               stddev[1] += (results_modified[c].duration - average[1]) * 
(results_modified[c].duration - average[1]);
        }
-       stddev /= c_modified;
-       stddev = sqrt (stddev);
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified average: %f stddev: 
%f\n", average, stddev);
+       stddev[1] /= c_modified;
+       stddev[1] = sqrt (stddev[1]);
+       if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified, 
%i measurements, average: %f stddev: %f\n",
+                       c_modified, average[1], stddev[1]);
 
-       average = 0.0;
+       average[2] = 0.0;
        for (c=0; c<c_unmodified;c++)
        {
-               average += (double) results_unmodified[c].duration;
+               average[2] += (double) results_unmodified[c].duration;
        }
-       average /= c_unmodified;
-       stddev = 0.0;
+       average[2] /= c_unmodified;
+       stddev[2] = 0.0;
        for (c=0; c<c_unmodified;c++)
        {
-               stddev += (results_unmodified[c].duration - average) * 
(results_unmodified[c].duration - average);
+               stddev[2] += (results_unmodified[c].duration - average[2]) * 
(results_unmodified[c].duration - average[2]);
        }
-       stddev /= c_unmodified;
-       stddev = sqrt (stddev);
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified average: %f stddev: 
%f\n", average, stddev);
+       stddev[2] /= c_unmodified;
+       stddev[2] = sqrt (stddev[2]);
 
+       if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified, 
%i measurements, average: %f stddev: %f\n",
+                       c_unmodified, average[2], stddev[2]);
 
-
-
-
+       if (machine_parsable)
+               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,",peers,%i,mechs,%i,"
+                                       "new,%i,%f,%f,"
+                                       "mod,%i,%f,%f,"
+                                       "unmod,%i,%f,%f\n",
+                                       peers-1, results_unmodified[0].mechs,
+                                       c_new, average[0], stddev[0],
+                                       c_modified, average[1], stddev[1],
+                                       c_unmodified, average[2], stddev[2]);
        shutdown_peers();
 }
 
@@ -310,6 +324,9 @@
                measurement_started = GNUNET_YES;
                count = 1;
                GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers 
connected\n", value);
+#if !VERBOSE
+               if (!machine_parsable)  fprintf(stderr, "%i", count);
+#endif
     }
 
     if (measurement_started == GNUNET_YES)
@@ -367,9 +384,11 @@
                                count ++;
 
                                GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(new: %i 
/ modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified , 
MEASUREMENTS);
-                               if ((count > MEASUREMENTS * 4) || ((c_modified 
>= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)))
+                               if ((count > MEASUREMENTS * 5) || ((c_modified 
>= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)))
                                {
-                                       fprintf(stdout, "\n");
+#if !VERBOSE
+                                       if (!machine_parsable) fprintf(stdout, 
"\n");
+#endif
                                        if (stats_task != 
GNUNET_SCHEDULER_NO_TASK)
                                        {
                                                
GNUNET_SCHEDULER_cancel(stats_task);
@@ -381,6 +400,9 @@
 
                                printed = GNUNET_NO;
                                current.timestamp = value;
+#if !VERBOSE
+                               if (!machine_parsable) fprintf(stderr, "..%i", 
count);
+#endif
                                return GNUNET_OK;
                        }
                }
@@ -628,7 +650,7 @@
 {
   char *const argv[] = { "test-testing",
     "-c",
-    "test_transport_ats.conf",
+    config_file,
 #if VERBOSE
     "-L", "DEBUG",
 #endif
@@ -662,13 +684,36 @@
                     NULL);
   GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
 
+  machine_parsable = GNUNET_NO;
   peers = NUM_PEERS;
-  if (argc == 2)
+  config_file = "test_transport_ats_1addr.conf";
+
+  int c = 0;
+  if (argc >= 2)
   {
-         peers = atoi(argv[1]);
-         peers++;
+        for (c=0; c<argc; c++)
+        {
+                /* set peers */
+                if ((strcmp(argv[c], "-p") == 0) && c < (argc-1))
+                {
+                         peers = atoi(argv[c+1]);
+                         peers++;
+                }
+                /* set machine parsable */
+                if (strcmp(argv[c], "-m") == 0)
+                {
+                        machine_parsable = GNUNET_YES;
+                }
+                /* set config file */
+                if ((strcmp(argv[c], "-c") == 0) && c < (argc-1))
+                {
+                        config_file = argv[c+1];
+                }
+        }
   }
 
+
+
   ret = check ();
   /**
    * Still need to remove the base testing directory here,




reply via email to

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