diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-27 15:54:11 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-27 15:54:11 +0000 |
commit | f23d6e3aa72999d08f4660c5ab3bbe1cc2d242c1 (patch) | |
tree | c0b88aca7b4f63da61f5e83849ab4ef84337571d /src/ats/perf_ats_solver.c | |
parent | 2e7e731865654bde25f222151b70b5b96df67d52 (diff) | |
download | gnunet-f23d6e3aa72999d08f4660c5ab3bbe1cc2d242c1.tar.gz gnunet-f23d6e3aa72999d08f4660c5ab3bbe1cc2d242c1.zip |
logging average
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r-- | src/ats/perf_ats_solver.c | 196 |
1 files changed, 188 insertions, 8 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 6f1a1a921..8d8b07739 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -609,11 +609,12 @@ solver_info_cb (void *cls, | |||
609 | } | 609 | } |
610 | 610 | ||
611 | static void | 611 | static void |
612 | write_gnuplot_script (char * data_fn, int full) | 612 | write_gnuplot_script (char * data_fn, int iteration, int full) |
613 | { | 613 | { |
614 | struct GNUNET_DISK_FileHandle *f; | 614 | struct GNUNET_DISK_FileHandle *f; |
615 | char * gfn; | 615 | char * gfn; |
616 | char *data; | 616 | char *data; |
617 | char *iter_text; | ||
617 | char *template; | 618 | char *template; |
618 | 619 | ||
619 | /* Write header */ | 620 | /* Write header */ |
@@ -640,11 +641,29 @@ write_gnuplot_script (char * data_fn, int full) | |||
640 | GNUNET_break (0); | 641 | GNUNET_break (0); |
641 | return; | 642 | return; |
642 | } | 643 | } |
643 | 644 | if (-1 == iteration) | |
645 | GNUNET_asprintf (&iter_text, "%s_%u", "avg",ph.iterations); | ||
646 | else | ||
647 | GNUNET_asprintf (&iter_text, "%u", iteration); | ||
644 | if (GNUNET_YES == full) | 648 | if (GNUNET_YES == full) |
645 | GNUNET_asprintf (&gfn, "perf_%s_full_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | 649 | { |
650 | GNUNET_asprintf (&gfn, "perf_%s_full_%s-%u_%u_%u.gnuplot", | ||
651 | ph.ats_string, | ||
652 | iter_text, | ||
653 | ph.N_peers_start, | ||
654 | ph.N_peers_end, | ||
655 | ph.N_address); | ||
656 | } | ||
646 | else | 657 | else |
647 | GNUNET_asprintf (&gfn, "perf_%s_update_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | 658 | { |
659 | GNUNET_asprintf (&gfn, "perf_%s_updat_%s-%u_%u_%u.gnuplot", | ||
660 | ph.ats_string, | ||
661 | iter_text, | ||
662 | ph.N_peers_start, | ||
663 | ph.N_peers_end, | ||
664 | ph.N_address); | ||
665 | } | ||
666 | GNUNET_free (iter_text); | ||
648 | 667 | ||
649 | f = GNUNET_DISK_file_open (gfn, | 668 | f = GNUNET_DISK_file_open (gfn, |
650 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 669 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
@@ -725,6 +744,7 @@ evaluate (int iteration) | |||
725 | char * str_d_setup; | 744 | char * str_d_setup; |
726 | char * str_d_lp; | 745 | char * str_d_lp; |
727 | char * str_d_mlp; | 746 | char * str_d_mlp; |
747 | char * iter_text; | ||
728 | 748 | ||
729 | f_full = NULL; | 749 | f_full = NULL; |
730 | f_update = NULL; | 750 | f_update = NULL; |
@@ -733,12 +753,18 @@ evaluate (int iteration) | |||
733 | 753 | ||
734 | if (ph.create_plot) | 754 | if (ph.create_plot) |
735 | { | 755 | { |
756 | if (-1 == iteration) | ||
757 | GNUNET_asprintf (&iter_text, "%s", "avg"); | ||
758 | else | ||
759 | GNUNET_asprintf (&iter_text, "%u", iteration); | ||
736 | GNUNET_asprintf (&data_fn_full, | 760 | GNUNET_asprintf (&data_fn_full, |
737 | "perf_%s_full_%u_%u_%u.data", | 761 | "perf_%s_full_%s_%u_%u_%u.data", |
738 | ph.ats_string, | 762 | ph.ats_string, |
763 | iter_text, | ||
739 | ph.N_peers_start, | 764 | ph.N_peers_start, |
740 | ph.N_peers_end, | 765 | ph.N_peers_end, |
741 | ph.N_address); | 766 | ph.N_address); |
767 | GNUNET_free (iter_text); | ||
742 | f_full = GNUNET_DISK_file_open (data_fn_full, | 768 | f_full = GNUNET_DISK_file_open (data_fn_full, |
743 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 769 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
744 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 770 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
@@ -755,17 +781,23 @@ evaluate (int iteration) | |||
755 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 781 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
756 | "Cannot write data to log file `%s'\n", | 782 | "Cannot write data to log file `%s'\n", |
757 | data_fn_full); | 783 | data_fn_full); |
758 | write_gnuplot_script (data_fn_full, GNUNET_YES); | 784 | write_gnuplot_script (data_fn_full, iteration, GNUNET_YES); |
759 | } | 785 | } |
760 | 786 | ||
761 | data_fn_update = NULL; | 787 | data_fn_update = NULL; |
762 | if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) | 788 | if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) |
763 | { | 789 | { |
764 | GNUNET_asprintf (&data_fn_update, "perf_%s_update_%u_%u_%u.data", | 790 | if (-1 == iteration) |
791 | GNUNET_asprintf (&iter_text, "%s", "avg"); | ||
792 | else | ||
793 | GNUNET_asprintf (&iter_text, "%u", iteration); | ||
794 | GNUNET_asprintf (&data_fn_update, "perf_%s_update_i%u_%u_%u_%u.data", | ||
765 | ph.ats_string, | 795 | ph.ats_string, |
796 | iter_text, | ||
766 | ph.N_peers_start, | 797 | ph.N_peers_start, |
767 | ph.N_peers_end, | 798 | ph.N_peers_end, |
768 | ph.N_address); | 799 | ph.N_address); |
800 | GNUNET_free (iter_text); | ||
769 | f_update = GNUNET_DISK_file_open (data_fn_update, | 801 | f_update = GNUNET_DISK_file_open (data_fn_update, |
770 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 802 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
771 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 803 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
@@ -784,7 +816,7 @@ evaluate (int iteration) | |||
784 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 816 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
785 | "Cannot write data to log file `%s'\n", | 817 | "Cannot write data to log file `%s'\n", |
786 | data_fn_update); | 818 | data_fn_update); |
787 | write_gnuplot_script (data_fn_update, GNUNET_NO); | 819 | write_gnuplot_script (data_fn_update, iteration, GNUNET_NO); |
788 | } | 820 | } |
789 | 821 | ||
790 | next = ph.iterations_results[ph.current_iteration -1].result_head; | 822 | next = ph.iterations_results[ph.current_iteration -1].result_head; |
@@ -913,35 +945,183 @@ static void | |||
913 | evaluate_average (void) | 945 | evaluate_average (void) |
914 | { | 946 | { |
915 | int c; | 947 | int c; |
948 | |||
949 | struct GNUNET_DISK_FileHandle *f_full; | ||
950 | struct GNUNET_DISK_FileHandle *f_update; | ||
951 | char * data_fn_full; | ||
952 | char * data_fn_update; | ||
953 | char * data; | ||
954 | char * str_d_total; | ||
955 | char * str_d_setup; | ||
956 | char * str_d_lp; | ||
957 | char * str_d_mlp; | ||
958 | |||
959 | f_full = NULL; | ||
960 | f_update = NULL; | ||
961 | |||
962 | data_fn_full = NULL; | ||
963 | |||
964 | if (ph.create_plot) | ||
965 | { | ||
966 | GNUNET_asprintf (&data_fn_full, | ||
967 | "perf_%s_full_avg_%u-%u_%u_%u.data", | ||
968 | ph.ats_string, | ||
969 | ph.iterations, | ||
970 | ph.N_peers_start, | ||
971 | ph.N_peers_end, | ||
972 | ph.N_address); | ||
973 | f_full = GNUNET_DISK_file_open (data_fn_full, | ||
974 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
975 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
976 | if (NULL == f_full) | ||
977 | { | ||
978 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
979 | "Cannot open gnuplot file `%s'\n", | ||
980 | data_fn_full); | ||
981 | GNUNET_free (data_fn_full); | ||
982 | return; | ||
983 | } | ||
984 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | ||
985 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) | ||
986 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
987 | "Cannot write data to log file `%s'\n", | ||
988 | data_fn_full); | ||
989 | write_gnuplot_script (data_fn_full, -1, GNUNET_YES); | ||
990 | } | ||
991 | |||
992 | data_fn_update = NULL; | ||
993 | if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) | ||
994 | { | ||
995 | GNUNET_asprintf (&data_fn_update, "perf_%s_update_avg_%u-%u_%u_%u.data", | ||
996 | ph.ats_string, | ||
997 | ph.iterations, | ||
998 | ph.N_peers_start, | ||
999 | ph.N_peers_end, | ||
1000 | ph.N_address); | ||
1001 | f_update = GNUNET_DISK_file_open (data_fn_update, | ||
1002 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
1003 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
1004 | if (NULL == f_update) | ||
1005 | { | ||
1006 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1007 | "Cannot open gnuplot file `%s'\n", data_fn_update); | ||
1008 | GNUNET_free (data_fn_update); | ||
1009 | if (NULL != f_full) | ||
1010 | GNUNET_DISK_file_close (f_full); | ||
1011 | GNUNET_free (data_fn_full); | ||
1012 | return; | ||
1013 | } | ||
1014 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | ||
1015 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) | ||
1016 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1017 | "Cannot write data to log file `%s'\n", | ||
1018 | data_fn_update); | ||
1019 | write_gnuplot_script (data_fn_update, -1, GNUNET_NO); | ||
1020 | } | ||
1021 | |||
916 | for (c = 0; c <= ph.N_peers_end - ph.N_peers_start; c++) | 1022 | for (c = 0; c <= ph.N_peers_end - ph.N_peers_start; c++) |
917 | { | 1023 | { |
918 | struct Result *cur = &ph.averaged_result[c]; | 1024 | struct Result *cur = &ph.averaged_result[c]; |
1025 | |||
1026 | str_d_total = NULL; | ||
1027 | str_d_setup = NULL; | ||
1028 | str_d_lp = NULL; | ||
1029 | str_d_mlp = NULL; | ||
1030 | |||
919 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) | 1031 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) |
1032 | { | ||
920 | fprintf (stderr, | 1033 | fprintf (stderr, |
921 | "Average total time to solve %s for %u peers %u addresses: %llu us\n", | 1034 | "Average total time to solve %s for %u peers %u addresses: %llu us\n", |
922 | (GNUNET_YES == cur->update) ? "updated" : "full", | 1035 | (GNUNET_YES == cur->update) ? "updated" : "full", |
923 | cur->peers, cur->addresses, | 1036 | cur->peers, cur->addresses, |
924 | (unsigned long long) cur->d_total.rel_value_us / ph.iterations); | 1037 | (unsigned long long) cur->d_total.rel_value_us / ph.iterations); |
1038 | GNUNET_asprintf(&str_d_total, "%llu", | ||
1039 | (unsigned long long) cur->d_total.rel_value_us / ph.iterations); | ||
1040 | } | ||
1041 | else | ||
1042 | GNUNET_asprintf (&str_d_total, "-1"); | ||
925 | 1043 | ||
926 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) | 1044 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) |
1045 | { | ||
927 | fprintf (stderr, | 1046 | fprintf (stderr, |
928 | "Average total time to setup for %u peers %u addresses: %llu us\n", | 1047 | "Average total time to setup for %u peers %u addresses: %llu us\n", |
929 | cur->peers, cur->addresses, | 1048 | cur->peers, cur->addresses, |
930 | (unsigned long long) cur->d_setup.rel_value_us / ph.iterations); | 1049 | (unsigned long long) cur->d_setup.rel_value_us / ph.iterations); |
1050 | GNUNET_asprintf(&str_d_setup, "%llu", | ||
1051 | (unsigned long long) cur->d_setup.rel_value_us / ph.iterations); | ||
1052 | |||
1053 | } | ||
1054 | else | ||
1055 | GNUNET_asprintf (&str_d_setup, "-1"); | ||
1056 | |||
931 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) | 1057 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) |
1058 | { | ||
932 | fprintf (stderr, | 1059 | fprintf (stderr, |
933 | "Average total time to solve lp %s for %u peers %u addresses: %llu us\n", | 1060 | "Average total time to solve lp %s for %u peers %u addresses: %llu us\n", |
934 | (GNUNET_YES == cur->update) ? "updated" : "full", | 1061 | (GNUNET_YES == cur->update) ? "updated" : "full", |
935 | cur->peers, cur->addresses, | 1062 | cur->peers, cur->addresses, |
936 | (unsigned long long) cur->d_lp.rel_value_us / ph.iterations); | 1063 | (unsigned long long) cur->d_lp.rel_value_us / ph.iterations); |
1064 | GNUNET_asprintf(&str_d_lp, "%llu", | ||
1065 | (unsigned long long) cur->d_lp.rel_value_us / ph.iterations); | ||
1066 | } | ||
1067 | else | ||
1068 | GNUNET_asprintf (&str_d_lp, "-1"); | ||
1069 | |||
937 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) | 1070 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) |
1071 | { | ||
938 | fprintf (stderr, | 1072 | fprintf (stderr, |
939 | "Average total time to solve mlp %s for %u peers %u addresses: %llu us\n", | 1073 | "Average total time to solve mlp %s for %u peers %u addresses: %llu us\n", |
940 | (GNUNET_YES == cur->update) ? "updated" : "full", | 1074 | (GNUNET_YES == cur->update) ? "updated" : "full", |
941 | cur->peers, cur->addresses, | 1075 | cur->peers, cur->addresses, |
942 | (unsigned long long) cur->d_mlp.rel_value_us / ph.iterations); | 1076 | (unsigned long long) cur->d_mlp.rel_value_us / ph.iterations); |
1077 | GNUNET_asprintf(&str_d_mlp, "%llu", | ||
1078 | (unsigned long long) cur->d_mlp.rel_value_us / ph.iterations); | ||
1079 | } | ||
1080 | else | ||
1081 | GNUNET_asprintf (&str_d_mlp, "-1"); | ||
1082 | |||
1083 | data = NULL; | ||
1084 | if (GNUNET_YES == ph.create_plot) | ||
1085 | { | ||
1086 | GNUNET_asprintf (&data, | ||
1087 | "%u;%u;%s;%s;%s;%s\n", | ||
1088 | cur->peers, cur->addresses, | ||
1089 | str_d_total, | ||
1090 | str_d_setup, | ||
1091 | str_d_lp, | ||
1092 | str_d_mlp); | ||
1093 | if (cur->update == GNUNET_NO) | ||
1094 | { | ||
1095 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data))) | ||
1096 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1097 | "Cannot write data to log file `%s'\n", | ||
1098 | data_fn_full); | ||
1099 | } | ||
1100 | if ((cur->update == GNUNET_YES) && (NULL != f_update)) | ||
1101 | { | ||
1102 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) | ||
1103 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1104 | "Cannot write data to log file `%s'\n", | ||
1105 | data_fn_update); | ||
1106 | } | ||
1107 | GNUNET_free (data); | ||
1108 | } | ||
1109 | |||
1110 | GNUNET_free_non_null (str_d_total); | ||
1111 | GNUNET_free_non_null (str_d_setup); | ||
1112 | GNUNET_free_non_null (str_d_lp); | ||
1113 | GNUNET_free_non_null (str_d_mlp); | ||
943 | } | 1114 | } |
944 | 1115 | ||
1116 | if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full))) | ||
1117 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | ||
1118 | data_fn_full); | ||
1119 | GNUNET_free_non_null (data_fn_full); | ||
1120 | |||
1121 | if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update))) | ||
1122 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | ||
1123 | data_fn_update); | ||
1124 | GNUNET_free_non_null (data_fn_update); | ||
945 | } | 1125 | } |
946 | 1126 | ||
947 | static void | 1127 | static void |