summaryrefslogtreecommitdiff
path: root/src/rps/test_rps.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-04-11 14:41:00 +0200
committerJulius Bünger <buenger@mytum.de>2018-04-11 14:42:11 +0200
commitae7bf7b653bd4977e94e29c3db73fdff8a8b8cfa (patch)
tree532f4b6c48a1e2fb488fd612e597b3696bd0cc97 /src/rps/test_rps.c
parent38c918ff27e5a90c1a17f3989a78c7fca564c47a (diff)
downloadgnunet-ae7bf7b653bd4977e94e29c3db73fdff8a8b8cfa.tar.gz
gnunet-ae7bf7b653bd4977e94e29c3db73fdff8a8b8cfa.zip
rps profiler: fix computation of probab, debugging
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r--src/rps/test_rps.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 60a743167..fa2ffd9eb 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -1958,7 +1958,7 @@ static void compute_probabilities (uint32_t peer_idx)
1958{ 1958{
1959 //double probs[num_peers] = { 0 }; 1959 //double probs[num_peers] = { 0 };
1960 double probs[num_peers]; 1960 double probs[num_peers];
1961 size_t probs_as_str_size = (num_peers * 6 + 1) * sizeof (char); 1961 size_t probs_as_str_size = (num_peers * 10 + 1) * sizeof (char);
1962 char *probs_as_str = GNUNET_malloc (probs_as_str_size); 1962 char *probs_as_str = GNUNET_malloc (probs_as_str_size);
1963 char *probs_as_str_cpy; 1963 char *probs_as_str_cpy;
1964 uint32_t i; 1964 uint32_t i;
@@ -1998,6 +1998,10 @@ static void compute_probabilities (uint32_t peer_idx)
1998 peer_idx, 1998 peer_idx,
1999 i, 1999 i,
2000 prob_push); 2000 prob_push);
2001 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2002 "\t\tposs choices from view: %f, containing i: %f\n",
2003 binom (view_size, 0.45 * view_size),
2004 binom (0.45 * view_size, 1));
2001 } else { 2005 } else {
2002 prob_push = 0; 2006 prob_push = 0;
2003 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2007 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2013,7 +2017,9 @@ static void compute_probabilities (uint32_t peer_idx)
2013 binom (view_size - cont_views, 0.45 * view_size)); 2017 binom (view_size - cont_views, 0.45 * view_size));
2014 if (0 != number_of_being_in_pull_events) 2018 if (0 != number_of_being_in_pull_events)
2015 { 2019 {
2016 prob_pull = 1.0 / number_of_being_in_pull_events; 2020 prob_pull = number_of_being_in_pull_events
2021 /
2022 (1.0 * binom (view_size, 0.45 * view_size));
2017 } else 2023 } else
2018 { 2024 {
2019 prob_pull = 0; 2025 prob_pull = 0;
@@ -2062,7 +2068,7 @@ static void compute_probabilities (uint32_t peer_idx)
2062 probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size); 2068 probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
2063 tmp = GNUNET_snprintf (probs_as_str, 2069 tmp = GNUNET_snprintf (probs_as_str,
2064 probs_as_str_size, 2070 probs_as_str_size,
2065 "%s %3.2f", probs_as_str_cpy, probs[i]); 2071 "%s %7.6f", probs_as_str_cpy, probs[i]);
2066 GNUNET_free (probs_as_str_cpy); 2072 GNUNET_free (probs_as_str_cpy);
2067 GNUNET_assert (0 <= tmp); 2073 GNUNET_assert (0 <= tmp);
2068 } 2074 }