diff options
author | Julius Bünger <buenger@mytum.de> | 2018-03-21 07:56:14 +0100 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-03-21 10:12:30 +0100 |
commit | 29d419cdf833f2b2115250373c1a015f12a017e1 (patch) | |
tree | 77bad5d08da45bbc8b17780924f834caaf39981b /src/rps | |
parent | 28e2cbb911ee174d17a5eb0de41465d668b133d0 (diff) |
rps profiler: restructure function
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/test_rps.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index e0f87652b6..127b973acc 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c @@ -1818,9 +1818,27 @@ store_stats_file_name (struct RPSPeer *rps_peer) rps_peer->file_name_stats = file_name; } +void count_peer_in_views (uint32_t *count_peers) +{ + uint32_t i, j; + + 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[i].peer_id, + &rps_peers[i].cur_view[j], + sizeof (struct GNUNET_PeerIdentity))) + { + count_peers[i]++; + } + } + } +} + void compute_diversity () { - uint32_t i, j, k; + uint32_t i; /* ith entry represents the numer of occurrences in other peer's views */ uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t); uint32_t views_total_size; @@ -1835,21 +1853,11 @@ void compute_diversity () for (i = 0; i < num_peers; i++) /* Peer to count */ { views_total_size += rps_peers[i].cur_view_count; - for (j = 0; j < num_peers; j++) /* Peer in which view is counted */ - { - for (k = 0; k < rps_peers[j].cur_view_count; k++) /* entry in view */ - { - if (0 == memcmp (rps_peers[i].peer_id, - &rps_peers[j].cur_view[k], - sizeof (struct GNUNET_PeerIdentity))) - { - count_peers[i]++; - } - } - } + count_peer_in_views (count_peers); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Counted representation of %" PRIu32 "th peer: %" PRIu32"\n", + "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32"\n", i, + GNUNET_i2s (rps_peers[i].peer_id), count_peers[i]); } |