[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 01/02: RPS profiler: Normalise correctly
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 01/02: RPS profiler: Normalise correctly |
Date: |
Wed, 10 Apr 2019 14:11:05 +0200 |
This is an automated email from the git hooks/post-receive script.
julius-buenger pushed a commit to branch master
in repository gnunet.
commit 20714e46c74f47d0ecc2359cbb4aa944ecc78135
Author: Julius Bünger <address@hidden>
AuthorDate: Wed Apr 10 14:07:28 2019 +0200
RPS profiler: Normalise correctly
---
src/rps/gnunet-rps-profiler.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index a13ee4078..474a83768 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -2232,7 +2232,7 @@ static void compute_probabilities (uint32_t peer_idx)
uint32_t cont_views;
uint32_t number_of_being_in_pull_events;
int tmp;
- uint32_t count_non_zero_prob = 0;
+ uint32_t sum_non_zero_prob = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Computing probabilities for peer %" PRIu32 "\n", peer_idx);
@@ -2315,21 +2315,14 @@ static void compute_probabilities (uint32_t peer_idx)
i,
number_of_being_in_pull_events);
- if (0 != probs[i]) count_non_zero_prob++;
+ sum_non_zero_prob += probs[i];
}
/* normalize */
- if (0 != count_non_zero_prob)
+ for (i = 0; i < num_peers; i++)
{
- for (i = 0; i < num_peers; i++)
- {
- probs[i] = probs[i] * (1.0 / count_non_zero_prob);
- }
- } else {
- for (i = 0; i < num_peers; i++)
- {
- probs[i] = 0;
- }
+ probs[i] = probs[i] * (1.0 / sum_non_zero_prob);
}
+
/* str repr */
for (i = 0; i < num_peers; i++)
{
--
To stop receiving notification emails like this one, please contact
address@hidden