+evaluate (int iteration)
+{
+ struct Result *cur;
+ int cp;
+
+ for (cp = ph.N_peers_start; cp <= ph.N_peers_end; cp ++)
+ {
+ cur = ph.iterations_results[ph.current_iteration-1].results_array[cp];
+ if (0 == cp)
+ continue;
+ if (NULL == cur)
+ {
+ GNUNET_break (0);
+ fprintf (stderr,
+ "Missing result for %u peers\n", cp);
+ }
+
+
+ if (GNUNET_NO == cur->valid)
+ {
+ fprintf (stderr,
+ "Total time to solve %s for %u peers %u addresses: %s\n",
+ (GNUNET_YES == cur->update) ? "updated" : "full",
+ cur->peers, cur->addresses, "Failed to solve!");
+ continue;
+ }
+
+
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total_full.rel_value_us)
+ {
+ fprintf (stderr,
+ "Total time to solve %s for %u peers %u addresses: %llu us\n",
+ (GNUNET_YES == cur->update) ? "updated" : "full",
+ cur->peers, cur->addresses,
+ (unsigned long long) cur->d_total_full.rel_value_us);
+ }
+
+
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup_full.rel_value_us)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Total time to setup %s %u peers %u addresses: %llu us\n",
+ (GNUNET_YES == cur->update) ? "updated" : "full",
+ cur->peers, cur->addresses,
+ (unsigned long long) cur->d_setup_full.rel_value_us);
+ }
+
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp_full.rel_value_us)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Total time to solve %s LP for %u peers %u addresses: %llu us\n",
+ (GNUNET_YES == cur->update) ? "updated" : "full",
+ cur->peers,
+ cur->addresses,
+ (unsigned long long )cur->d_lp_full.rel_value_us);
+ }
+
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp_full.rel_value_us)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Total time to solve %s MLP for %u peers %u addresses: %llu us\n",
+ (GNUNET_YES == cur->update) ? "updated" : "full",
+ cur->peers, cur->addresses,
+ (unsigned long long )cur->d_mlp_full.rel_value_us);
+ }
+ }
+
+}
+
+/**
+ * Evaluate average results for all iterations
+ */
+static void
+write_all_iterations (void)
+{
+ int c_iteration;
+ int c_peer;
+
+ struct GNUNET_DISK_FileHandle *f_full;
+ struct GNUNET_DISK_FileHandle *f_update;
+ char * data_fn_full;
+ char * data_fn_update;
+ char * data;
+
+ f_full = NULL;
+ f_update = NULL;
+
+ data_fn_full = NULL;
+
+ if (GNUNET_NO == ph.create_datafile)
+ return;
+
+ GNUNET_asprintf (&data_fn_full,
+ "perf_%s_full_%u-%u_%u_%u.data",
+ ph.ats_string,
+ ph.total_iterations,
+ ph.N_peers_start,
+ ph.N_peers_end,
+ ph.N_address);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Using data file `%s'\n",
+ data_fn_full);
+
+ f_full = GNUNET_DISK_file_open (data_fn_full,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == f_full)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Cannot open data file `%s'\n",
+ data_fn_full);
+ GNUNET_free (data_fn_full);
+ return;
+ }
+
+ data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to log file `%s'\n",
+ data_fn_full);
+
+ data_fn_update = NULL;
+ if (GNUNET_YES == ph.measure_updates)
+ {
+ GNUNET_asprintf (&data_fn_update, "perf_%s_update_%u-%u_%u_%u.data",
+ ph.ats_string,
+ ph.total_iterations,
+ ph.N_peers_start,
+ ph.N_peers_end,
+ ph.N_address);
+ f_update = GNUNET_DISK_file_open (data_fn_update,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == f_update)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Cannot open gnuplot file `%s'\n", data_fn_update);
+ GNUNET_free (data_fn_update);
+ if (NULL != f_full)
+ GNUNET_DISK_file_close (f_full);
+ GNUNET_free (data_fn_full);
+ return;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Using update data file `%s'\n",
+ data_fn_update);
+
+ data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to log file `%s'\n",
+ data_fn_update);
+ }
+
+ for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer ++)
+ {
+ char * data_str;
+ char * data_tmp;
+ char * data_upd_str;
+ char * data_upd_tmp;
+ GNUNET_asprintf(&data_str, "%u;%u",c_peer, ph.N_address);
+ if (ph.measure_updates)
+ GNUNET_asprintf(&data_upd_str, "%u;%u",c_peer, ph.N_address);
+ for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration ++)
+ {
+ struct Result *cur_full_res;
+ struct Result *cur_upd_res;
+
+
+
+ //fprintf (stderr, "P: %u I: %u == %p \n", c_peer, c_iteration, cur_res);
+ cur_full_res = ph.iterations_results[c_iteration].results_array[c_peer];
+ if (c_peer == 0)
+ continue;
+ if (NULL == cur_full_res)
+ continue;
+
+ if (ph.measure_updates)
+ {
+ cur_upd_res = ph.iterations_results[c_iteration].update_results_array[c_peer];
+ data_upd_tmp = GNUNET_strdup (data_upd_str);
+ GNUNET_free (data_upd_str);
+ if (GNUNET_YES == cur_full_res->valid)
+ {
+ GNUNET_asprintf (&data_upd_str, "%s;%llu", data_upd_tmp,
+ (NULL == cur_upd_res) ? 0 : cur_upd_res->d_total_full.rel_value_us);
+ }
+ else
+ {
+ GNUNET_asprintf (&data_upd_str, "%s;", data_upd_tmp);
+ }
+ GNUNET_free (data_upd_tmp);
+
+ }
+
+ //fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses);
+ //fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us);
+
+ data_tmp = GNUNET_strdup (data_str);
+ GNUNET_free (data_str);
+ if (GNUNET_YES == cur_full_res->valid)
+ {
+ GNUNET_asprintf (&data_str, "%s;%llu", data_tmp,
+ cur_full_res->d_total_full.rel_value_us);
+ }
+ else
+ {
+ GNUNET_asprintf (&data_str, "%s;", data_tmp);
+ }
+
+ GNUNET_free (data_tmp);
+ }
+ data_tmp = GNUNET_strdup (data_str);
+ GNUNET_free (data_str);
+ GNUNET_asprintf (&data_str, "%s\n", data_tmp);
+ GNUNET_free (data_tmp);
+
+ fprintf (stderr, "Result full solution: %s\n", data_str);
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data_str, strlen(data_str)))
+ GNUNET_break (0);
+ GNUNET_free (data_str);
+
+ if (ph.measure_updates)
+ {
+ data_upd_tmp = GNUNET_strdup (data_upd_str);
+ GNUNET_free (data_upd_str);
+ GNUNET_asprintf (&data_upd_str, "%s\n", data_upd_tmp);
+ GNUNET_free (data_upd_tmp);
+
+ fprintf (stderr, "Result updated solution: `%s'\n", data_upd_str);
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data_upd_str, strlen(data_upd_str)))
+ GNUNET_break (0);
+ GNUNET_free (data_upd_str);
+ }
+ }
+
+ if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
+ data_fn_full);
+ GNUNET_free_non_null (data_fn_full);
+
+ if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
+ data_fn_update);
+ GNUNET_free_non_null (data_fn_update);
+}
+
+/**
+ * Run a performance iteration
+ */
+
+static void
+perf_run_iteration (void)