From e645cf2194cf309c9597b21dc7d4fd2d011777e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julius=20B=C3=BCnger?= Date: Thu, 5 Apr 2018 01:10:28 +0200 Subject: [PATCH] rps profiler: log view counts --- src/rps/test_rps.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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 @@ -269,6 +269,11 @@ struct RPSPeer */ uint32_t cur_view_count; + /** + * @brief Number of occurrences in other peer's view + */ + uint32_t count_in_views; + /** * @brief statistics values */ @@ -1838,7 +1843,28 @@ store_stats_file_name (struct RPSPeer *rps_peer) rps_peer->file_name_stats = file_name; } -void count_peer_in_views (uint32_t *count_peers) +static uint32_t count_peer_in_views_2 (uint32_t peer_idx) +{ + uint32_t i, j; + uint32_t count = 0; + + for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ + { + for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */ + { + if (0 == memcmp (rps_peers[peer_idx].peer_id, + &rps_peers[i].cur_view[j], + sizeof (struct GNUNET_PeerIdentity))) + { + count++; + } + } + } + rps_peers[peer_idx].count_in_views = count; + return count; +} + +static void count_peer_in_views (uint32_t *count_peers) { uint32_t i, j; @@ -1941,6 +1967,10 @@ void view_update_cb (void *cls, memcpy (rps_peer->cur_view, peers, num_peers * sizeof (struct GNUNET_PeerIdentity)); + to_file ("/tmp/rps/count_in_views.txt", + "%" PRIu64 " %" PRIu32 "", + rps_peer->index, + count_peer_in_views_2 (rps_peer->index)); all_views_updated_cb(); } -- 2.25.1