summaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-03-21 07:56:51 +0100
committerJulius Bünger <buenger@mytum.de>2018-03-21 10:12:30 +0100
commit9d068580565b7ad49f5db5e3dae7b538f0f9bd5b (patch)
tree3727e33407c8e4457bf6808c05b5c6656f1c8bf4 /src/rps
parent29d419cdf833f2b2115250373c1a015f12a017e1 (diff)
rps profiler: log view sizes
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/rps-test_util.c18
-rw-r--r--src/rps/test_rps.c35
2 files changed, 48 insertions, 5 deletions
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 882f945c9..e492b76b7 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -43,6 +43,7 @@ to_file_ (char *file_name, char *line)
{
struct GNUNET_DISK_FileHandle *f;
char output_buffer[512];
+ char *output_buffer_p;
//size_t size;
int size;
size_t size2;
@@ -62,8 +63,14 @@ to_file_ (char *file_name, char *line)
file_name);
return;
}
- size = GNUNET_snprintf (output_buffer,
- sizeof (output_buffer),
+ if (512 < strlen (line) + 18)
+ {
+ output_buffer_p = GNUNET_malloc ((strlen (line) + 18) * sizeof (char));
+ } else {
+ output_buffer_p = &output_buffer[0];
+ }
+ size = GNUNET_snprintf (output_buffer_p,
+ sizeof (output_buffer_p),
"%llu %s\n",
GNUNET_TIME_absolute_get ().abs_value_us,
line);
@@ -75,7 +82,7 @@ to_file_ (char *file_name, char *line)
return;
}
- size2 = GNUNET_DISK_file_write (f, output_buffer, size);
+ size2 = GNUNET_DISK_file_write (f, output_buffer_p, size);
if (size != size2)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -90,6 +97,11 @@ to_file_ (char *file_name, char *line)
return;
}
+ if (512 < strlen (line) + 18)
+ {
+ GNUNET_free (output_buffer_p);
+ }
+
if (GNUNET_YES != GNUNET_DISK_file_close (f))
LOG (GNUNET_ERROR_TYPE_WARNING,
"Unable to close file\n");
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 127b973ac..d9f0a2c77 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -1878,9 +1878,40 @@ void compute_diversity ()
GNUNET_free (deviation);
}
-void all_views_updated_cb ()
+void print_view_sizes()
{
- compute_diversity ();
+ uint32_t i;
+ char *view_sizes_str = NULL;
+ uint32_t view_sizes_str_len = 0;
+ char view_size_curr[32] = { 0 };
+
+ GNUNET_array_grow (view_sizes_str, view_sizes_str_len, num_peers * 3);
+ for (i = 0; i < num_peers; i++) /* Peer to count */
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
+ i,
+ GNUNET_i2s (rps_peers[i].peer_id),
+ rps_peers[i].cur_view_count);
+ GNUNET_snprintf (view_size_curr,
+ sizeof (view_size_curr),
+ " %" PRIu32 "",
+ rps_peers[i].cur_view_count);
+ if (view_sizes_str_len < view_sizes_str_len + strlen (view_size_curr))
+ {
+ GNUNET_array_grow (view_sizes_str, view_sizes_str_len, view_sizes_str_len + 10);
+ }
+ strncat (view_sizes_str, view_size_curr, strlen(view_size_curr));
+ }
+ to_file_ ("/tmp/rps/view_sizes.txt",
+ view_sizes_str);
+ GNUNET_array_grow (view_sizes_str, view_sizes_str_len, 0);
+}
+
+void all_views_updated_cb()
+{
+ compute_diversity();
+ print_view_sizes();
}
void view_update_cb (void *cls,