aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-set-profiler.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-28 18:14:19 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-28 18:15:30 +0100
commitd1aa49fc2767aa141e83ba664cd1d10b3ad1987b (patch)
tree35c44a746caa9473bbcea8caa901b77db149a73b /src/set/gnunet-set-profiler.c
parentc9bc0115c53e10a31ffffb6dbb1cb85e77168dda (diff)
downloadgnunet-d1aa49fc2767aa141e83ba664cd1d10b3ad1987b.tar.gz
gnunet-d1aa49fc2767aa141e83ba664cd1d10b3ad1987b.zip
set profiler: allow variable element size via -w (width) option
Diffstat (limited to 'src/set/gnunet-set-profiler.c')
-rw-r--r--src/set/gnunet-set-profiler.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index d83e034a6..7de58a0d1 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -62,6 +62,8 @@ static int byzantine;
62static int force_delta; 62static int force_delta;
63static int force_full; 63static int force_full;
64 64
65static unsigned int element_length = 32;
66
65/** 67/**
66 * Handle to the statistics service. 68 * Handle to the statistics service.
67 */ 69 */
@@ -261,15 +263,17 @@ set_insert_iterator (void *cls,
261 void *value) 263 void *value)
262{ 264{
263 struct GNUNET_SET_Handle *set = cls; 265 struct GNUNET_SET_Handle *set = cls;
264 struct GNUNET_SET_Element *el; 266 struct GNUNET_SET_Element el;
265 267
266 el = GNUNET_malloc (sizeof (struct GNUNET_SET_Element) + 268 GNUNET_assert (element_length > 0);
267 sizeof (struct GNUNET_HashCode)); 269 char payload[element_length];
268 el->element_type = 0; 270
269 GNUNET_memcpy (&el[1], key, sizeof *key); 271 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, payload, element_length);
270 el->data = &el[1]; 272
271 el->size = sizeof *key; 273 el.element_type = 0;
272 GNUNET_SET_add_element (set, el, NULL, NULL); 274 el.data = payload;
275 el.size = element_length;
276 GNUNET_SET_add_element (set, &el, NULL, NULL);
273 GNUNET_free (el); 277 GNUNET_free (el);
274 return GNUNET_YES; 278 return GNUNET_YES;
275} 279}
@@ -432,6 +436,9 @@ main (int argc, char **argv)
432 { 'f', "force-full", NULL, 436 { 'f', "force-full", NULL,
433 gettext_noop ("force sending full set"), 437 gettext_noop ("force sending full set"),
434 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full }, 438 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full },
439 { 'l', "element-length", NULL,
440 gettext_noop ("element length in byte"),
441 GNUNET_NO, &GNUNET_GETOPT_set_uint, &element_length },
435 { 'd', "force-delta", NULL, 442 { 'd', "force-delta", NULL,
436 gettext_noop ("number delta operation"), 443 gettext_noop ("number delta operation"),
437 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta }, 444 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta },