diff options
author | Julius Bünger <buenger@mytum.de> | 2018-04-05 01:10:28 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-04-05 01:10:28 +0200 |
commit | e645cf2194cf309c9597b21dc7d4fd2d011777e0 (patch) | |
tree | 04e09797c899a47e30097fbd8fd01893b11b0c95 /src/rps/test_rps.c | |
parent | ea51d048c44b83c679ba22978a3a4b0ff1bf12b5 (diff) | |
download | gnunet-e645cf2194cf309c9597b21dc7d4fd2d011777e0.tar.gz gnunet-e645cf2194cf309c9597b21dc7d4fd2d011777e0.zip |
rps profiler: log view counts
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 660ac541a..e28210ed4 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -270,6 +270,11 @@ struct RPSPeer | |||
270 | uint32_t cur_view_count; | 270 | uint32_t cur_view_count; |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * @brief Number of occurrences in other peer's view | ||
274 | */ | ||
275 | uint32_t count_in_views; | ||
276 | |||
277 | /** | ||
273 | * @brief statistics values | 278 | * @brief statistics values |
274 | */ | 279 | */ |
275 | uint64_t num_rounds; | 280 | uint64_t num_rounds; |
@@ -1838,7 +1843,28 @@ store_stats_file_name (struct RPSPeer *rps_peer) | |||
1838 | rps_peer->file_name_stats = file_name; | 1843 | rps_peer->file_name_stats = file_name; |
1839 | } | 1844 | } |
1840 | 1845 | ||
1841 | void count_peer_in_views (uint32_t *count_peers) | 1846 | static uint32_t count_peer_in_views_2 (uint32_t peer_idx) |
1847 | { | ||
1848 | uint32_t i, j; | ||
1849 | uint32_t count = 0; | ||
1850 | |||
1851 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ | ||
1852 | { | ||
1853 | for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */ | ||
1854 | { | ||
1855 | if (0 == memcmp (rps_peers[peer_idx].peer_id, | ||
1856 | &rps_peers[i].cur_view[j], | ||
1857 | sizeof (struct GNUNET_PeerIdentity))) | ||
1858 | { | ||
1859 | count++; | ||
1860 | } | ||
1861 | } | ||
1862 | } | ||
1863 | rps_peers[peer_idx].count_in_views = count; | ||
1864 | return count; | ||
1865 | } | ||
1866 | |||
1867 | static void count_peer_in_views (uint32_t *count_peers) | ||
1842 | { | 1868 | { |
1843 | uint32_t i, j; | 1869 | uint32_t i, j; |
1844 | 1870 | ||
@@ -1941,6 +1967,10 @@ void view_update_cb (void *cls, | |||
1941 | memcpy (rps_peer->cur_view, | 1967 | memcpy (rps_peer->cur_view, |
1942 | peers, | 1968 | peers, |
1943 | num_peers * sizeof (struct GNUNET_PeerIdentity)); | 1969 | num_peers * sizeof (struct GNUNET_PeerIdentity)); |
1970 | to_file ("/tmp/rps/count_in_views.txt", | ||
1971 | "%" PRIu64 " %" PRIu32 "", | ||
1972 | rps_peer->index, | ||
1973 | count_peer_in_views_2 (rps_peer->index)); | ||
1944 | all_views_updated_cb(); | 1974 | all_views_updated_cb(); |
1945 | } | 1975 | } |
1946 | 1976 | ||