-static void
-write_gnuplot_script (char * data_fn, int iteration, int full)
-{
- struct GNUNET_DISK_FileHandle *f;
- char * gfn;
- char *data;
- char *iter_text;
- char *template;
-
- /* Write header */
- switch (ph.ats_mode) {
- case MODE_PROPORTIONAL:
- if (GNUNET_YES == full)
- template = GNUPLOT_PROP_TEMPLATE;
- else
- template = GNUPLOT_PROP_UPDATE_TEMPLATE;
- break;
- case MODE_MLP:
- if (GNUNET_YES == full)
- template = GNUPLOT_MLP_TEMPLATE;
- else
- template = GNUPLOT_MLP_UPDATE_TEMPLATE;
- break;
- case MODE_RIL:
- if (GNUNET_YES == full)
- template = GNUPLOT_RIL_TEMPLATE;
- else
- template = GNUPLOT_RIL_UPDATE_TEMPLATE;
- break;
- default:
- GNUNET_break (0);
- return;
- }
- if (-1 == iteration)
- GNUNET_asprintf (&iter_text, "%s_%u", "avg",ph.total_iterations);
- else
- GNUNET_asprintf (&iter_text, "%u", iteration);
- if (GNUNET_YES == full)
- {
- GNUNET_asprintf (&gfn, "perf_%s_full_%s-%u_%u_%u.gnuplot",
- ph.ats_string,
- iter_text,
- ph.N_peers_start,
- ph.N_peers_end,
- ph.N_address);
- }
- else
- {
- GNUNET_asprintf (&gfn, "perf_%s_updat_%s-%u_%u_%u.gnuplot",
- ph.ats_string,
- iter_text,
- ph.N_peers_start,
- ph.N_peers_end,
- ph.N_address);
- }
- GNUNET_free (iter_text);
-
- f = GNUNET_DISK_file_open (gfn,
- 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)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
- GNUNET_free (gfn);
- return;
- }
-
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, template, strlen(template)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
-
- data = NULL;
- if (MODE_PROPORTIONAL == ph.ats_mode)
- {
- GNUNET_asprintf (&data, "plot '%s' using 1:%u with lines title 'Total time to solve'\n" \
- "pause -1",
- data_fn, 3);
- }
- else if (MODE_MLP == ph.ats_mode)
- {
- GNUNET_asprintf (&data, "plot '%s' using 1:%u with lines title 'Total time to solve',\\\n" \
- "'%s' using 1:%u with lines title 'Time to setup',\\\n"
- "'%s' using 1:%u with lines title 'Time to solve LP',\\\n"
- "'%s' using 1:%u with lines title 'Total time to solve MLP'\n" \
- "pause -1",
- data_fn, 3,
- data_fn, 4,
- data_fn, 5,
- data_fn, 6);
- }
- else if (MODE_RIL == ph.ats_mode)
- {
- GNUNET_asprintf (&data,
- "plot '%s' using 1:%u with lines title 'Total time to solve'\n" \
- "pause -1",
- data_fn, 3);
- }
-
- if ((NULL != data) &&
- (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen(data))))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to plot file `%s'\n",
- gfn);
- GNUNET_free_non_null (data);
-
- if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot close gnuplot file `%s'\n",
- gfn);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Data successfully written to plot file `%s'\n",
- gfn);
- GNUNET_free (gfn);
-
-}
-