aboutsummaryrefslogtreecommitdiff
path: root/src/rps/test_rps.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-03-21 10:31:04 +0100
committerJulius Bünger <buenger@mytum.de>2018-03-21 11:07:34 +0100
commit77b71b4106bea8f2e229fd610aca3dcfbc56d34f (patch)
tree886763271630efa2a70447790bd115ac29f82709 /src/rps/test_rps.c
parent9d068580565b7ad49f5db5e3dae7b538f0f9bd5b (diff)
downloadgnunet-77b71b4106bea8f2e229fd610aca3dcfbc56d34f.tar.gz
gnunet-77b71b4106bea8f2e229fd610aca3dcfbc56d34f.zip
rps profiler: collect statistics
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r--src/rps/test_rps.c179
1 files changed, 174 insertions, 5 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index d9f0a2c77..93a406aaf 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -268,6 +268,26 @@ struct RPSPeer
268 * @brief Number of peers in the #cur_view. 268 * @brief Number of peers in the #cur_view.
269 */ 269 */
270 uint32_t cur_view_count; 270 uint32_t cur_view_count;
271
272 /**
273 * @brief statistics values
274 */
275 uint64_t num_rounds;
276 uint64_t num_blocks;
277 uint64_t num_blocks_many_push;
278 uint64_t num_blocks_no_push;
279 uint64_t num_blocks_no_pull;
280 uint64_t num_blocks_many_push_no_pull;
281 uint64_t num_blocks_no_push_no_pull;
282 uint64_t num_issued_push;
283 uint64_t num_issued_pull_req;
284 uint64_t num_issued_pull_rep;
285 uint64_t num_sent_push;
286 uint64_t num_sent_pull_req;
287 uint64_t num_sent_pull_rep;
288 uint64_t num_recv_push;
289 uint64_t num_recv_pull_req;
290 uint64_t num_recv_pull_rep;
271}; 291};
272 292
273enum STAT_TYPE 293enum STAT_TYPE
@@ -1942,6 +1962,37 @@ pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1942 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); 1962 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
1943} 1963}
1944 1964
1965void write_final_stats (void){
1966 uint32_t i;
1967
1968 for (i = 0; i < num_peers; i++)
1969 {
1970 to_file ("/tmp/rps/final_stats.dat",
1971 "%s %" PRIu64
1972 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 /* blocking */
1973 " %" PRIu64 " %" PRIu64 " %" PRIu64 /* issued */
1974 " %" PRIu64 " %" PRIu64 " %" PRIu64 /* sent */
1975 " %" PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
1976 GNUNET_i2s (rps_peers[i].peer_id),
1977 rps_peers[i].num_rounds,
1978 rps_peers[i].num_blocks,
1979 rps_peers[i].num_blocks_many_push,
1980 rps_peers[i].num_blocks_no_push,
1981 rps_peers[i].num_blocks_no_pull,
1982 rps_peers[i].num_blocks_many_push_no_pull,
1983 rps_peers[i].num_blocks_no_push_no_pull,
1984 rps_peers[i].num_issued_push,
1985 rps_peers[i].num_issued_pull_req,
1986 rps_peers[i].num_issued_pull_rep,
1987 rps_peers[i].num_sent_push,
1988 rps_peers[i].num_sent_pull_req,
1989 rps_peers[i].num_sent_pull_rep,
1990 rps_peers[i].num_recv_push,
1991 rps_peers[i].num_recv_pull_req,
1992 rps_peers[i].num_recv_pull_rep);
1993 }
1994}
1995
1945/** 1996/**
1946 * Continuation called by #GNUNET_STATISTICS_get() functions. 1997 * Continuation called by #GNUNET_STATISTICS_get() functions.
1947 * 1998 *
@@ -1979,6 +2030,7 @@ post_test_shutdown_ready_cb (void *cls,
1979 2030
1980 if (GNUNET_YES == check_statistics_collect_completed()) 2031 if (GNUNET_YES == check_statistics_collect_completed())
1981 { 2032 {
2033 write_final_stats ();
1982 GNUNET_free (stat_cls); 2034 GNUNET_free (stat_cls);
1983 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1984 "Shutting down\n"); 2036 "Shutting down\n");
@@ -1989,6 +2041,83 @@ post_test_shutdown_ready_cb (void *cls,
1989} 2041}
1990 2042
1991/** 2043/**
2044 * @brief Converts string representation to the corresponding #STAT_TYPE enum.
2045 *
2046 * @param stat_str string representation of statistics specifier
2047 *
2048 * @return corresponding enum
2049 */
2050enum STAT_TYPE stat_str_2_type (const char *stat_str)
2051{
2052 if (GNUNET_YES == strncmp ("# rounds", stat_str, strlen ("# rounds")))
2053 {
2054 return STAT_TYPE_ROUNDS;
2055 }
2056 if (GNUNET_YES == strncmp ("# rounds blocked", stat_str, strlen ("# rounds blocked")))
2057 {
2058 return STAT_TYPE_BLOCKS;
2059 }
2060 if (0 == strncmp ("# rounds blocked - too many pushes", stat_str, strlen ("# rounds blocked - too many pushes")))
2061 {
2062 return STAT_TYPE_BLOCKS_MANY_PUSH;
2063 }
2064 if (0 == strncmp ("# rounds blocked - no pushes", stat_str, strlen ("# rounds blocked - no pushes")))
2065 {
2066 return STAT_TYPE_BLOCKS_NO_PUSH;
2067 }
2068 if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ("# rounds blocked - no pull replies")))
2069 {
2070 return STAT_TYPE_BLOCKS_NO_PULL;
2071 }
2072 if (0 == strncmp ("# rounds blocked - too many pushes, no pull replies", stat_str, strlen ("# rounds blocked - too many pushes, no pull replies")))
2073 {
2074 return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL;
2075 }
2076 if (0 == strncmp ("# rounds blocked - no pushes, no pull replies", stat_str, strlen ("# rounds blocked - no pushes, no pull replies")))
2077 {
2078 return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL;
2079 }
2080 if (0 == strncmp ("# push send issued", stat_str, strlen ("# push send issued")))
2081 {
2082 return STAT_TYPE_ISSUED_PUSH_SEND;
2083 }
2084 if (0 == strncmp ("# pull request send issued", stat_str, strlen ("# pull request send issued")))
2085 {
2086 return STAT_TYPE_ISSUED_PULL_REQ;
2087 }
2088 if (0 == strncmp ("# pull reply send issued", stat_str, strlen ("# pull reply send issued")))
2089 {
2090 return STAT_TYPE_ISSUED_PULL_REP;
2091 }
2092 if (0 == strncmp ("# pushes sent", stat_str, strlen ("# pushes sent")))
2093 {
2094 return STAT_TYPE_SENT_PUSH_SEND;
2095 }
2096 if (0 == strncmp ("# pull requests sent", stat_str, strlen ("# pull requests sent")))
2097 {
2098 return STAT_TYPE_SENT_PULL_REQ;
2099 }
2100 if (0 == strncmp ("# pull replys sent", stat_str, strlen ("# pull replys sent")))
2101 {
2102 return STAT_TYPE_SENT_PULL_REP;
2103 }
2104 if (0 == strncmp ("# push message received", stat_str, strlen ("# push message received")))
2105 {
2106 return STAT_TYPE_RECV_PUSH_SEND;
2107 }
2108 if (0 == strncmp ("# pull request message received", stat_str, strlen ("# pull request message received")))
2109 {
2110 return STAT_TYPE_RECV_PULL_REQ;
2111 }
2112 if (0 == strncmp ("# pull reply messages received", stat_str, strlen ("# pull reply messages received")))
2113 {
2114 return STAT_TYPE_RECV_PULL_REP;
2115 }
2116 return STAT_TYPE_MAX;
2117}
2118
2119
2120/**
1992 * @brief Converts #STAT_TYPE enum to the equivalent string representation that 2121 * @brief Converts #STAT_TYPE enum to the equivalent string representation that
1993 * is stored with the statistics service. 2122 * is stored with the statistics service.
1994 * 2123 *
@@ -2057,15 +2186,55 @@ stat_iterator (void *cls,
2057 int is_persistent) 2186 int is_persistent)
2058{ 2187{
2059 const struct STATcls *stat_cls = (const struct STATcls *) cls; 2188 const struct STATcls *stat_cls = (const struct STATcls *) cls;
2060 const struct RPSPeer *rps_peer = (const struct RPSPeer *) stat_cls->rps_peer; 2189 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
2061 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", 2190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
2062 //stat_type_2_str (stat_cls->stat_type), 2191 //stat_type_2_str (stat_cls->stat_type),
2063 name, 2192 name,
2064 value); 2193 value);
2065 to_file (rps_peer->file_name_stats, 2194 //to_file (rps_peer->file_name_stats,
2066 "%s: %" PRIu64 "\n", 2195 // "%s: %" PRIu64 "\n",
2067 name, 2196 // name,
2068 value); 2197 // value);
2198 switch (stat_str_2_type (name))
2199 {
2200 case STAT_TYPE_ROUNDS:
2201 rps_peer->num_blocks = value;
2202 case STAT_TYPE_BLOCKS:
2203 rps_peer->num_blocks = value;
2204 case STAT_TYPE_BLOCKS_MANY_PUSH:
2205 rps_peer->num_blocks_many_push = value;
2206 case STAT_TYPE_BLOCKS_NO_PUSH:
2207 rps_peer->num_blocks_no_push = value;
2208 case STAT_TYPE_BLOCKS_NO_PULL:
2209 rps_peer->num_blocks_no_pull = value;
2210 case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
2211 rps_peer->num_blocks_many_push_no_pull = value;
2212 case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
2213 rps_peer->num_blocks_no_push_no_pull = value;
2214 case STAT_TYPE_ISSUED_PUSH_SEND:
2215 rps_peer->num_issued_push = value;
2216 case STAT_TYPE_ISSUED_PULL_REQ:
2217 rps_peer->num_issued_pull_req = value;
2218 case STAT_TYPE_ISSUED_PULL_REP:
2219 rps_peer->num_issued_pull_rep = value;
2220 case STAT_TYPE_SENT_PUSH_SEND:
2221 rps_peer->num_sent_push = value;
2222 case STAT_TYPE_SENT_PULL_REQ:
2223 rps_peer->num_sent_pull_req = value;
2224 case STAT_TYPE_SENT_PULL_REP:
2225 rps_peer->num_sent_pull_rep = value;
2226 case STAT_TYPE_RECV_PUSH_SEND:
2227 rps_peer->num_recv_push = value;
2228 case STAT_TYPE_RECV_PULL_REQ:
2229 rps_peer->num_recv_pull_req = value;
2230 case STAT_TYPE_RECV_PULL_REP:
2231 rps_peer->num_recv_pull_rep = value;
2232 case STAT_TYPE_MAX:
2233 default:
2234 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2235 "Unknown statistics string: %s\n",
2236 name);
2237 }
2069 return GNUNET_OK; 2238 return GNUNET_OK;
2070} 2239}
2071 2240