aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats_solver.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-10-30 16:35:50 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-10-30 16:35:50 +0000
commit65e76227902ef9db39f94b1af8765566b31a1b2a (patch)
tree5e5a2401ba244d3eced40e12a41595be0f06c0dd /src/ats/perf_ats_solver.c
parentfbe5b7ab37b85a80a96481af0608cd87ff70f61d (diff)
downloadgnunet-65e76227902ef9db39f94b1af8765566b31a1b2a.tar.gz
gnunet-65e76227902ef9db39f94b1af8765566b31a1b2a.zip
gnuplot basics
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r--src/ats/perf_ats_solver.c136
1 files changed, 136 insertions, 0 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index 631594b06..3be4c9775 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -37,6 +37,27 @@
37#define DEFAULT_ADDRESSES 10 37#define DEFAULT_ADDRESSES 10
38#define DEFAULT_ATS_COUNT 2 38#define DEFAULT_ATS_COUNT 2
39 39
40#define GNUPLOT_PROP_TEMPLATE "#!/usr/bin/gnuplot \n" \
41"set datafile separator ';' \n" \
42"set title \"Execution time Proportional solver \" \n" \
43"set xlabel \"Time in us\" \n" \
44"set ylabel \"Bytes/s\" \n" \
45"set grid \n"
46
47#define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \
48"set datafile separator ';' \n" \
49"set title \"Execution time MLP solver \" \n" \
50"set xlabel \"Time in us\" \n" \
51"set ylabel \"Bytes/s\" \n" \
52"set grid \n"
53
54#define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \
55"set datafile separator ';' \n" \
56"set title \"Execution time RIL solver \" \n" \
57"set xlabel \"Time in us\" \n" \
58"set ylabel \"Bytes/s\" \n" \
59"set grid \n"
60
40/** 61/**
41 * Handle for ATS address component 62 * Handle for ATS address component
42 */ 63 */
@@ -112,6 +133,11 @@ struct PerfHandle
112 int opt_update_quantity; 133 int opt_update_quantity;
113 134
114 /** 135 /**
136 * Create gnuplot file
137 */
138 int create_plot;
139
140 /**
115 * Is a bulk operation running? 141 * Is a bulk operation running?
116 */ 142 */
117 int bulk_running; 143 int bulk_running;
@@ -485,11 +511,117 @@ solver_info_cb (void *cls, enum GAS_Solver_Operation op,
485} 511}
486 512
487static void 513static void
514write_gnuplot_script ()
515{
516 struct Result *cur;
517 struct Result *next;
518 struct GNUNET_DISK_FileHandle *f;
519 char * gfn;
520 char *data;
521 char *template;
522 int c_s;
523 int index;
524 int plot_d_total;
525 int plot_d_setup;
526 int plot_d_lp;
527 int plot_d_mlp;
528
529 GNUNET_asprintf (&gfn, "perf_%s_%u_%u_%u", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
530 f = GNUNET_DISK_file_open (gfn,
531 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
532 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
533 if (NULL == f)
534 {
535 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
536 GNUNET_free (gfn);
537 return;
538 }
539
540 /* Write header */
541
542 switch (ph.ats_mode) {
543 case MODE_PROPORTIONAL:
544 template = GNUPLOT_PROP_TEMPLATE;
545 break;
546 case MODE_MLP:
547 template = GNUPLOT_MLP_TEMPLATE;
548 break;
549 case MODE_RIL:
550 template = GNUPLOT_RIL_TEMPLATE;
551 break;
552 default:
553 break;
554 }
555
556 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, template, strlen(template)))
557 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
558#if 0
559 cur = ph.head->d_total;
560 if (cur->d_total != GNUNET_TIME_relative_get_forever_().rel_value_us)
561 plot_d_total = GNUNET_YES;
562
563 if (cur->d_total != GNUNET_TIME_relative_get_forever_().rel_value_us)
564 plot_d_total = GNUNET_YES;
565 if (cur->d_setup != GNUNET_TIME_relative_get_forever_().rel_value_us)
566 plot_d_setup = GNUNET_YES;
567 if (cur->d_lp != GNUNET_TIME_relative_get_forever_().rel_value_us)
568 plot_d_lp = GNUNET_YES;
569 if (cur->d_mlp != GNUNET_TIME_relative_get_forever_().rel_value_us)
570 plot_d_mlp = GNUNET_YES;
571
572
573 GNUNET_asprintf (&data, "plot "\
574 "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \
575 "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\
576 "%s\n",
577 "\n pause -1",
578 fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, lp->peer->partners[c_s].dest->no,
579 fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, lp->peer->partners[c_s].dest->no);
580
581 GNUNET_free (data);
582#endif
583 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
584 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
585
586
587#if 0
588 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER;
589 for (c_s = 0; c_s < lp->peer->num_partners; c_s++)
590 {
591 GNUNET_asprintf (&data, "%s"\
592 "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \
593 "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\
594 "%s\n",
595 (0 == c_s) ? "plot " :"",
596 fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, lp->peer->partners[c_s].dest->no,
597 fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, lp->peer->partners[c_s].dest->no,
598 (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1");
599
600 GNUNET_free (data);
601 index += LOG_ITEMS_PER_PEER;
602 }
603#endif
604
605 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
606 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
607 else
608 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
609 GNUNET_free (gfn);
610
611}
612
613
614static void
488evaluate () 615evaluate ()
489{ 616{
490 struct Result *cur; 617 struct Result *cur;
491 struct Result *next; 618 struct Result *next;
492 619
620 if (ph.create_plot)
621 {
622 write_gnuplot_script ();
623 }
624
493 next = ph.head; 625 next = ph.head;
494 while (NULL != (cur = next)) 626 while (NULL != (cur = next))
495 { 627 {
@@ -770,6 +902,7 @@ main (int argc, char *argv[])
770 ph.N_peers_end = 0; 902 ph.N_peers_end = 0;
771 ph.N_address = 0; 903 ph.N_address = 0;
772 ph.ats_string = NULL; 904 ph.ats_string = NULL;
905 ph.create_plot = GNUNET_NO;
773 906
774 static struct GNUNET_GETOPT_CommandLineOption options[] = { 907 static struct GNUNET_GETOPT_CommandLineOption options[] = {
775 { 'a', "addresses", NULL, 908 { 'a', "addresses", NULL,
@@ -787,6 +920,9 @@ main (int argc, char *argv[])
787 { 'q', "quantity", NULL, 920 { 'q', "quantity", NULL,
788 gettext_noop ("update a fix quantity of addresses"), 921 gettext_noop ("update a fix quantity of addresses"),
789 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_quantity }, 922 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_quantity },
923 { 'g', "gnuplot", NULL,
924 gettext_noop ("create GNUplot file"),
925 0, &GNUNET_GETOPT_set_one, &ph.create_plot},
790 GNUNET_GETOPT_OPTION_END 926 GNUNET_GETOPT_OPTION_END
791 }; 927 };
792 928