[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 02/03: rps profiler: restructure function
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 02/03: rps profiler: restructure function |
Date: |
Wed, 21 Mar 2018 10:12:57 +0100 |
This is an automated email from the git hooks/post-receive script.
julius-buenger pushed a commit to branch master
in repository gnunet.
commit 29d419cdf833f2b2115250373c1a015f12a017e1
Author: Julius Bünger <address@hidden>
AuthorDate: Wed Mar 21 07:56:14 2018 +0100
rps profiler: restructure function
---
src/rps/test_rps.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index e0f87652b..127b973ac 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]);
}
--
To stop receiving notification emails like this one, please contact
address@hidden