diff options
author | Julius Bünger <buenger@mytum.de> | 2018-04-06 12:42:16 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-04-06 12:43:03 +0200 |
commit | 1f754809a913093ba215b6b6689d28b7dfb66e4c (patch) | |
tree | b265708e4a9d48d7f3d48e5e5aa7adc52dbd3657 /src/rps/test_rps.c | |
parent | a42b440b3c072304d2a0af8676acb754df9c9f7b (diff) | |
download | gnunet-1f754809a913093ba215b6b6689d28b7dfb66e4c.tar.gz gnunet-1f754809a913093ba215b6b6689d28b7dfb66e4c.zip |
rps profiler: collect more data
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index e28210ed4..6ee665ad5 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -354,6 +354,11 @@ static struct RPSPeer *eval_peer; | |||
354 | static unsigned int num_peers_online; | 354 | static unsigned int num_peers_online; |
355 | 355 | ||
356 | /** | 356 | /** |
357 | * @brief The added sizes of the peer's views | ||
358 | */ | ||
359 | static unsigned int view_sizes; | ||
360 | |||
361 | /** | ||
357 | * Return value from 'main'. | 362 | * Return value from 'main'. |
358 | */ | 363 | */ |
359 | static int ok; | 364 | static int ok; |
@@ -1843,6 +1848,15 @@ store_stats_file_name (struct RPSPeer *rps_peer) | |||
1843 | rps_peer->file_name_stats = file_name; | 1848 | rps_peer->file_name_stats = file_name; |
1844 | } | 1849 | } |
1845 | 1850 | ||
1851 | /** | ||
1852 | * @brief This counts the number of peers in which views a given peer occurs. | ||
1853 | * | ||
1854 | * It also stores this value in the rps peer. | ||
1855 | * | ||
1856 | * @param peer_idx the index of the peer to count the representation | ||
1857 | * | ||
1858 | * @return the number of occurrences | ||
1859 | */ | ||
1846 | static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | 1860 | static uint32_t count_peer_in_views_2 (uint32_t peer_idx) |
1847 | { | 1861 | { |
1848 | uint32_t i, j; | 1862 | uint32_t i, j; |
@@ -1857,6 +1871,7 @@ static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | |||
1857 | sizeof (struct GNUNET_PeerIdentity))) | 1871 | sizeof (struct GNUNET_PeerIdentity))) |
1858 | { | 1872 | { |
1859 | count++; | 1873 | count++; |
1874 | break; | ||
1860 | } | 1875 | } |
1861 | } | 1876 | } |
1862 | } | 1877 | } |
@@ -1864,6 +1879,18 @@ static uint32_t count_peer_in_views_2 (uint32_t peer_idx) | |||
1864 | return count; | 1879 | return count; |
1865 | } | 1880 | } |
1866 | 1881 | ||
1882 | static uint32_t cumulated_view_sizes () | ||
1883 | { | ||
1884 | uint32_t i; | ||
1885 | |||
1886 | view_sizes = 0; | ||
1887 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ | ||
1888 | { | ||
1889 | view_sizes += rps_peers[i].cur_view_count; | ||
1890 | } | ||
1891 | return view_sizes; | ||
1892 | } | ||
1893 | |||
1867 | static void count_peer_in_views (uint32_t *count_peers) | 1894 | static void count_peer_in_views (uint32_t *count_peers) |
1868 | { | 1895 | { |
1869 | uint32_t i, j; | 1896 | uint32_t i, j; |
@@ -1945,32 +1972,49 @@ void all_views_updated_cb() | |||
1945 | } | 1972 | } |
1946 | 1973 | ||
1947 | void view_update_cb (void *cls, | 1974 | void view_update_cb (void *cls, |
1948 | uint64_t num_peers, | 1975 | uint64_t view_size, |
1949 | const struct GNUNET_PeerIdentity *peers) | 1976 | const struct GNUNET_PeerIdentity *peers) |
1950 | { | 1977 | { |
1951 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1978 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1952 | "View was updated (%" PRIu64 ")\n", num_peers); | 1979 | "View was updated (%" PRIu64 ")\n", view_size); |
1953 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | 1980 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; |
1954 | to_file ("/tmp/rps/view_sizes.txt", | 1981 | to_file ("/tmp/rps/view_sizes.txt", |
1955 | "%" PRIu64 " %" PRIu32 "", | 1982 | "%" PRIu64 " %" PRIu32 "", |
1956 | rps_peer->index, | 1983 | rps_peer->index, |
1957 | num_peers); | 1984 | view_size); |
1958 | for (int i = 0; i < num_peers; i++) | 1985 | for (int i = 0; i < view_size; i++) |
1959 | { | 1986 | { |
1960 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1987 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1961 | "\t%s\n", GNUNET_i2s (&peers[i])); | 1988 | "\t%s\n", GNUNET_i2s (&peers[i])); |
1962 | } | 1989 | } |
1963 | GNUNET_array_grow (rps_peer->cur_view, | 1990 | GNUNET_array_grow (rps_peer->cur_view, |
1964 | rps_peer->cur_view_count, | 1991 | rps_peer->cur_view_count, |
1965 | num_peers); | 1992 | view_size); |
1966 | //*rps_peer->cur_view = *peers; | 1993 | //*rps_peer->cur_view = *peers; |
1967 | memcpy (rps_peer->cur_view, | 1994 | memcpy (rps_peer->cur_view, |
1968 | peers, | 1995 | peers, |
1969 | num_peers * sizeof (struct GNUNET_PeerIdentity)); | 1996 | view_size * sizeof (struct GNUNET_PeerIdentity)); |
1970 | to_file ("/tmp/rps/count_in_views.txt", | 1997 | to_file ("/tmp/rps/count_in_views.txt", |
1971 | "%" PRIu64 " %" PRIu32 "", | 1998 | "%" PRIu64 " %" PRIu32 "", |
1972 | rps_peer->index, | 1999 | rps_peer->index, |
1973 | count_peer_in_views_2 (rps_peer->index)); | 2000 | count_peer_in_views_2 (rps_peer->index)); |
2001 | cumulated_view_sizes(); | ||
2002 | to_file ("/tmp/rps/repr.txt", | ||
2003 | "%" PRIu64 /* index */ | ||
2004 | " %" PRIu32 /* occurrence in views */ | ||
2005 | " %" PRIu32 /* view sizes */ | ||
2006 | " %f" /* fraction of repr in views */ | ||
2007 | " %f" /* average view size */ | ||
2008 | " %f" /* prob of occurrence in view slot */ | ||
2009 | " %f" "", /* exp frac of repr in views */ | ||
2010 | rps_peer->index, | ||
2011 | count_peer_in_views_2 (rps_peer->index), | ||
2012 | view_sizes, | ||
2013 | count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */ | ||
2014 | view_sizes / (view_size * 1.0), /* average view size */ | ||
2015 | 1.0 /view_size, /* prob of occurrence in view slot */ | ||
2016 | (1.0/view_size) * (view_sizes/view_size) /* expected fraction of repr in views */ | ||
2017 | ); | ||
1974 | all_views_updated_cb(); | 2018 | all_views_updated_cb(); |
1975 | } | 2019 | } |
1976 | 2020 | ||