aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-rps-profiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r--src/rps/gnunet-rps-profiler.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 5ef42187f..4a7a89b15 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -42,6 +42,11 @@
42static uint32_t num_peers; 42static uint32_t num_peers;
43 43
44/** 44/**
45 * @brief numer of bits required to represent the largest peer id
46 */
47static unsigned bits_needed;
48
49/**
45 * How long do we run the test? 50 * How long do we run the test?
46 * In seconds. 51 * In seconds.
47 */ 52 */
@@ -1698,6 +1703,7 @@ profiler_reply_handle (void *cls,
1698 char *file_name; 1703 char *file_name;
1699 char *file_name_dh; 1704 char *file_name_dh;
1700 char *file_name_dhr; 1705 char *file_name_dhr;
1706 char *file_name_dhru;
1701 unsigned int i; 1707 unsigned int i;
1702 struct PendingReply *pending_rep = (struct PendingReply *) cls; 1708 struct PendingReply *pending_rep = (struct PendingReply *) cls;
1703 1709
@@ -1706,6 +1712,7 @@ profiler_reply_handle (void *cls,
1706 file_name = "/tmp/rps/received_ids"; 1712 file_name = "/tmp/rps/received_ids";
1707 file_name_dh = "/tmp/rps/diehard_input"; 1713 file_name_dh = "/tmp/rps/diehard_input";
1708 file_name_dhr = "/tmp/rps/diehard_input_raw"; 1714 file_name_dhr = "/tmp/rps/diehard_input_raw";
1715 file_name_dhru = "/tmp/rps/diehard_input_raw_aligned";
1709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1710 "[%s] got %" PRIu64 " peers:\n", 1717 "[%s] got %" PRIu64 " peers:\n",
1711 GNUNET_i2s (rps_peer->peer_id), 1718 GNUNET_i2s (rps_peer->peer_id),
@@ -1725,8 +1732,12 @@ profiler_reply_handle (void *cls,
1725 "%" PRIu32 "\n", 1732 "%" PRIu32 "\n",
1726 (uint32_t) rcv_rps_peer->index); 1733 (uint32_t) rcv_rps_peer->index);
1727 to_file_raw (file_name_dhr, 1734 to_file_raw (file_name_dhr,
1728 &rcv_rps_peer->index, 1735 (char *) &rcv_rps_peer->index,
1729 sizeof (uint32_t)); 1736 sizeof (uint32_t));
1737 to_file_raw_unaligned (file_name_dhru,
1738 (char *) &rcv_rps_peer->index,
1739 sizeof (uint32_t),
1740 bits_needed);
1730 } 1741 }
1731 default_reply_handle (cls, n, recv_peers); 1742 default_reply_handle (cls, n, recv_peers);
1732} 1743}
@@ -2626,6 +2637,14 @@ run (void *cls,
2626 GNUNET_DISK_directory_create ("/tmp/rps/"); 2637 GNUNET_DISK_directory_create ("/tmp/rps/");
2627 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_s); 2638 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_s);
2628 2639
2640 /* Compute number of bits for representing largest peer id */
2641 for (bits_needed = 1; (bits_needed << 1) < num_peers - 1; bits_needed++)
2642 ;
2643 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2644 "Need %u bits to represent largest peer id %" PRIu32 "\n",
2645 bits_needed,
2646 num_peers - 1);
2647
2629 rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); 2648 rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
2630 peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO); 2649 peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
2631 rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); 2650 rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);