GNUnet  0.11.x
Data Structures | Functions | Variables
gnunet-seti-profiler.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_seti_service.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-seti-profiler.c:

Go to the source code of this file.

Data Structures

struct  SetInfo
 

Functions

static int map_remove_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static int statistics_result (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Callback function to process statistic values. More...
 
static void statistics_done (void *cls, int success)
 
static void check_all_done (void)
 
static void set_result_cb (void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)
 
static void set_listen_cb (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)
 
static int set_insert_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void handle_shutdown (void *cls)
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
 
static void pre_run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
int main (int argc, char **argv)
 

Variables

static int ret
 
static unsigned int num_a = 5
 
static unsigned int num_b = 5
 
static unsigned int num_c = 20
 
static const struct GNUNET_CONFIGURATION_Handleconfig
 
struct SetInfo info1
 
struct SetInfo info2
 
static struct GNUNET_CONTAINER_MultiHashMapcommon_sent
 
static struct GNUNET_HashCode app_id
 
static struct GNUNET_PeerIdentity local_peer
 
static struct GNUNET_SETI_ListenHandleset_listener
 
static unsigned int use_intersection
 
static unsigned int element_size = 32
 
static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service. More...
 
static char * statistics_filename
 The profiler will write statistics for all peers to the file with this name. More...
 
static FILE * statistics_file
 The profiler will write statistics for all peers to this file. More...
 

Function Documentation

◆ map_remove_iterator()

static int map_remove_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 82 of file gnunet-seti-profiler.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_OK, GNUNET_YES, m, and ret.

Referenced by check_all_done().

85 {
86  struct GNUNET_CONTAINER_MultiHashMap *m = cls;
87  int ret;
88 
89  GNUNET_assert (NULL != key);
90 
92  if (GNUNET_OK != ret)
93  printf ("spurious element\n");
94  return GNUNET_YES;
95 }
static int ret
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
Internal representation of the hash map.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
Here is the call graph for this function:
Here is the caller graph for this function:

◆ statistics_result()

static int statistics_result ( void *  cls,
const char *  subsystem,
const char *  name,
uint64_t  value,
int  is_persistent 
)
static

Callback function to process statistic values.

Parameters
clsclosure
subsystemname of subsystem that created the statistic
namethe name of the datum
valuethe current value
is_persistentGNUNET_YES if the value is persistent, GNUNET_NO if not
Returns
GNUNET_OK to continue, GNUNET_SYSERR to abort iteration

Definition at line 109 of file gnunet-seti-profiler.c.

References GNUNET_OK, and statistics_file.

Referenced by check_all_done().

114 {
115  if (NULL != statistics_file)
116  {
117  fprintf (statistics_file, "%s\t%s\t%lu\n", subsystem, name, (unsigned
118  long) value);
119  }
120  return GNUNET_OK;
121 }
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
static char * value
Value of the record to add/remove.
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
const char * name
Here is the caller graph for this function:

◆ statistics_done()

static void statistics_done ( void *  cls,
int  success 
)
static

Definition at line 125 of file gnunet-seti-profiler.c.

References GNUNET_assert, GNUNET_SCHEDULER_shutdown(), GNUNET_YES, and statistics_file.

Referenced by check_all_done().

127 {
128  GNUNET_assert (GNUNET_YES == success);
129  if (NULL != statistics_file)
130  fclose (statistics_file);
132 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_all_done()

static void check_all_done ( void  )
static

Definition at line 136 of file gnunet-seti-profiler.c.

References SetInfo::done, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_get(), info1, info2, map_remove_iterator(), SetInfo::received, SetInfo::sent, statistics_done(), statistics_file, statistics_filename, and statistics_result().

Referenced by set_result_cb().

137 {
138  if ((info1.done == GNUNET_NO) || (info2.done == GNUNET_NO))
139  return;
140 
142  info2.sent);
144  info1.sent);
145 
146  printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
147  info1.sent));
148  printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
149  info2.sent));
150 
151  if (NULL == statistics_filename)
152  {
154  return;
155  }
156 
157  statistics_file = fopen (statistics_filename, "w");
158  GNUNET_STATISTICS_get (statistics, NULL, NULL,
160  &statistics_result, NULL);
161 }
static void statistics_done(void *cls, int success)
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiHashMap * received
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
struct SetInfo info1
static int statistics_result(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values.
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static char * statistics_filename
The profiler will write statistics for all peers to the file with this name.
struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls)
Get statistic from the peer.
static int map_remove_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_CONTAINER_MultiHashMap * sent
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct SetInfo info2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_result_cb()

static void set_result_cb ( void *  cls,
const struct GNUNET_SETI_Element element,
uint64_t  current_size,
enum GNUNET_SETI_Status  status 
)
static

Definition at line 165 of file gnunet-seti-profiler.c.

References check_all_done(), GNUNET_SETI_Element::data, SetInfo::done, element_size, GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_SETI_STATUS_ADD_LOCAL, GNUNET_SETI_STATUS_DEL_LOCAL, GNUNET_SETI_STATUS_DONE, GNUNET_SETI_STATUS_FAILURE, GNUNET_YES, SetInfo::id, SetInfo::oh, SetInfo::received, and GNUNET_SETI_Element::size.

Referenced by run(), and set_listen_cb().

169 {
170  struct SetInfo *info = cls;
171  struct GNUNET_HashCode hash;
172 
173  GNUNET_assert (GNUNET_NO == info->done);
174  switch (status)
175  {
177  info->done = GNUNET_YES;
179  "set intersection done\n");
180  check_all_done ();
181  info->oh = NULL;
182  return;
184  info->oh = NULL;
186  "failure\n");
188  return;
190  GNUNET_CRYPTO_hash (element->data,
191  element->size,
192  &hash);
194  "set %s: keep element %s\n",
195  info->id,
196  GNUNET_h2s (&hash));
197  break;
199  GNUNET_CRYPTO_hash (element->data,
200  element->size,
201  &hash);
203  "set %s: remove element %s\n",
204  info->id,
205  GNUNET_h2s (&hash));
206  return;
207  default:
208  GNUNET_assert (0);
209  }
210 
211  if (element->size != element_size)
212  {
214  "wrong element size: %u, expected %u\n",
215  element->size,
216  (unsigned int) sizeof(struct GNUNET_HashCode));
217  GNUNET_assert (0);
218  }
219 
221  "set %s: got element (%s)\n",
222  info->id, GNUNET_h2s (element->data));
223  GNUNET_assert (NULL != element->data);
224  {
225  struct GNUNET_HashCode data_hash;
226 
227  GNUNET_CRYPTO_hash (element->data,
228  element_size,
229  &data_hash);
231  &data_hash,
232  NULL,
234  }
235 }
Success, all elements have been sent (and received).
The other peer refused to do the operation with us, or something went wrong.
If a value with the given key exists, replace it.
uint16_t size
Number of bytes in the buffer pointed to by data.
struct GNUNET_CONTAINER_MultiHashMap * received
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
Element should be added to the result set of the local peer, i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
uint16_t status
See PRISM_STATUS_*-constants.
const void * data
Actual data of the element.
A 512-bit hashcode.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Element should be delete from the result set of the local peer, i.e.
static void check_all_done(void)
#define GNUNET_log(kind,...)
static unsigned int element_size
struct GNUNET_SET_OperationHandle * oh
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_listen_cb()

static void set_listen_cb ( void *  cls,
const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_MessageHeader context_msg,
struct GNUNET_SETI_Request request 
)
static

Definition at line 239 of file gnunet-seti-profiler.c.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SETI_accept(), GNUNET_SETI_commit(), GNUNET_SETI_OPTION_END, GNUNET_SETI_OPTION_RETURN_INTERSECTION, info2, SetInfo::oh, SetInfo::set, set_result_cb(), GNUNET_SETI_Option::type, and use_intersection.

Referenced by run().

243 {
244  /* max. 1 option plus terminator */
245  struct GNUNET_SETI_Option opts[2] = { { 0 } };
246  unsigned int n_opts = 0;
247 
248  if (NULL == request)
249  {
251  "listener failed\n");
252  return;
253  }
254  GNUNET_assert (NULL == info2.oh);
256  "set listen cb called\n");
257  if (use_intersection)
258  {
259  opts[n_opts++] = (struct GNUNET_SETI_Option) { .type =
261  }
262  opts[n_opts].type = GNUNET_SETI_OPTION_END;
263  info2.oh = GNUNET_SETI_accept (request,
264  opts,
265  &set_result_cb,
266  &info2);
268  info2.set);
269 }
int GNUNET_SETI_commit(struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set)
Commit a set to be used with a set operation.
Definition: seti_api.c:836
Option for set operations.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned int use_intersection
enum GNUNET_SETI_OptionType type
Type of the option.
struct GNUNET_SETI_OperationHandle * GNUNET_SETI_accept(struct GNUNET_SETI_Request *request, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETI_listen().
Definition: seti_api.c:780
struct GNUNET_SET_Handle * set
#define GNUNET_log(kind,...)
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL). ...
static void set_result_cb(void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)
struct GNUNET_SET_OperationHandle * oh
struct SetInfo info2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_insert_iterator()

static int set_insert_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 273 of file gnunet-seti-profiler.c.

References GNUNET_SETI_Element::data, element_size, GNUNET_SETI_Element::element_type, GNUNET_SETI_add_element(), GNUNET_YES, GNUNET_SETI_Element::size, and value.

Referenced by run().

276 {
277  struct GNUNET_SETI_Handle *set = cls;
278  struct GNUNET_SETI_Element el;
279 
280  el.element_type = 0;
281  el.data = value;
282  el.size = element_size;
283  GNUNET_SETI_add_element (set, &el, NULL, NULL);
284  return GNUNET_YES;
285 }
int GNUNET_SETI_add_element(struct GNUNET_SETI_Handle *set, const struct GNUNET_SETI_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
Definition: seti_api.c:447
Opaque handle to a set.
Definition: seti_api.c:39
static char * value
Value of the record to add/remove.
Element stored in a set.
static unsigned int element_size
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_shutdown()

static void handle_shutdown ( void *  cls)
static

Definition at line 289 of file gnunet-seti-profiler.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SETI_destroy(), GNUNET_SETI_listen_cancel(), GNUNET_SETI_operation_cancel(), GNUNET_STATISTICS_destroy(), info1, info2, SetInfo::oh, and SetInfo::set.

Referenced by run().

290 {
292  "Shutting down set profiler\n");
293  if (NULL != set_listener)
294  {
296  set_listener = NULL;
297  }
298  if (NULL != info1.oh)
299  {
301  info1.oh = NULL;
302  }
303  if (NULL != info2.oh)
304  {
306  info2.oh = NULL;
307  }
308  if (NULL != info1.set)
309  {
311  info1.set = NULL;
312  }
313  if (NULL != info2.set)
314  {
316  info2.set = NULL;
317  }
319 }
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct SetInfo info1
void GNUNET_SETI_operation_cancel(struct GNUNET_SETI_OperationHandle *oh)
Cancel the given set operation.
Definition: seti_api.c:335
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_SETI_ListenHandle * set_listener
struct GNUNET_SET_Handle * set
#define GNUNET_log(kind,...)
struct GNUNET_SET_OperationHandle * oh
void GNUNET_SETI_listen_cancel(struct GNUNET_SETI_ListenHandle *lh)
Cancel the given listen operation.
Definition: seti_api.c:747
struct SetInfo info2
void GNUNET_SETI_destroy(struct GNUNET_SETI_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: seti_api.c:488
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_TESTING_Peer peer 
)
static

Definition at line 323 of file gnunet-seti-profiler.c.

References app_id, cfg, data, element_size, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CRYPTO_get_peer_identity(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_create_random(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_block(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SETI_commit(), GNUNET_SETI_create(), GNUNET_SETI_destroy(), GNUNET_SETI_listen(), GNUNET_SETI_OPTION_END, GNUNET_SETI_OPTION_RETURN_INTERSECTION, GNUNET_SETI_prepare(), GNUNET_STATISTICS_create(), handle_shutdown(), SetInfo::id, info1, info2, local_peer, num_a, num_b, num_c, SetInfo::oh, SetInfo::received, ret, SetInfo::sent, SetInfo::set, set_insert_iterator(), set_listen_cb(), set_result_cb(), GNUNET_SETI_Option::type, and use_intersection.

Referenced by pre_run().

326 {
327  unsigned int i;
328  struct GNUNET_HashCode hash;
329  /* max. 1 option plus terminator */
330  struct GNUNET_SETI_Option opts[2] = { { 0 } };
331  unsigned int n_opts = 0;
332 
333  config = cfg;
334 
336 
338  {
340  "could not retrieve host identity\n");
341  ret = 0;
342  return;
343  }
344  statistics = GNUNET_STATISTICS_create ("set-profiler", cfg);
346  info1.id = "a";
347  info2.id = "b";
353  for (i = 0; i < num_a; i++)
354  {
355  char *data = GNUNET_malloc (element_size);
357  GNUNET_CRYPTO_hash (data, element_size, &hash);
360  }
361 
362  for (i = 0; i < num_b; i++)
363  {
364  char *data = GNUNET_malloc (element_size);
366  GNUNET_CRYPTO_hash (data, element_size, &hash);
369  }
370 
371  for (i = 0; i < num_c; i++)
372  {
373  char *data = GNUNET_malloc (element_size);
375  GNUNET_CRYPTO_hash (data, element_size, &hash);
378  }
379 
381 
386  info1.set);
389  info2.set);
392  info1.set);
395  info2.set);
396 
398  &app_id,
399  &set_listen_cb,
400  NULL);
401  if (use_intersection)
402  {
403  opts[n_opts++] = (struct GNUNET_SETI_Option) { .type =
405  }
406  opts[n_opts].type = GNUNET_SETI_OPTION_END;
407 
409  &app_id,
410  NULL,
411  opts,
413  &info1);
415  info1.set);
417  info1.set = NULL;
418 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
If a value with the given key exists, replace it.
static int set_insert_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
static int ret
int GNUNET_SETI_commit(struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set)
Commit a set to be used with a set operation.
Definition: seti_api.c:836
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1331
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_CONTAINER_MultiHashMap * received
Option for set operations.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned int num_c
static unsigned int use_intersection
struct GNUNET_SETI_ListenHandle * GNUNET_SETI_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETI_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: seti_api.c:715
struct SetInfo info1
enum GNUNET_SETI_OptionType type
Type of the option.
static struct GNUNET_HashCode app_id
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:144
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
static void set_listen_cb(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)
struct GNUNET_SETI_Handle * GNUNET_SETI_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set, supporting the specified operation.
Definition: seti_api.c:399
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
A 512-bit hashcode.
static struct GNUNET_PeerIdentity local_peer
static const struct GNUNET_CONFIGURATION_Handle * config
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static struct GNUNET_SETI_ListenHandle * set_listener
static struct GNUNET_CONTAINER_MultiHashMap * common_sent
struct GNUNET_SET_Handle * set
static unsigned int num_b
static unsigned int num_a
#define GNUNET_log(kind,...)
static unsigned int element_size
struct GNUNET_CONTAINER_MultiHashMap * sent
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host&#39;s peer.
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL). ...
static void set_result_cb(void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)
struct GNUNET_SET_OperationHandle * oh
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
uint32_t data
The data value.
struct SetInfo info2
static void handle_shutdown(void *cls)
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_SETI_OperationHandle * GNUNET_SETI_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: seti_api.c:526
void GNUNET_SETI_destroy(struct GNUNET_SETI_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: seti_api.c:488
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pre_run()

static void pre_run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 422 of file gnunet-seti-profiler.c.

References GNUNET_TESTING_peer_run(), ret, and run().

Referenced by main().

426 {
427  if (0 != GNUNET_TESTING_peer_run ("set-profiler",
428  cfgfile,
429  &run, NULL))
430  ret = 2;
431 }
static int ret
int GNUNET_TESTING_peer_run(const char *testdir, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single peer and run a test using the testing library.
Definition: testing.c:1590
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 435 of file gnunet-seti-profiler.c.

References element_size, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_uint(), GNUNET_PROGRAM_run2(), GNUNET_YES, num_a, num_b, num_c, pre_run(), ret, statistics_filename, and use_intersection.

436 {
439  "num-first",
440  NULL,
441  gettext_noop ("number of values"),
442  &num_a),
444  "num-second",
445  NULL,
446  gettext_noop ("number of values"),
447  &num_b),
449  "num-common",
450  NULL,
451  gettext_noop ("number of values"),
452  &num_c),
454  "use-intersection",
455  NULL,
456  gettext_noop (
457  "return intersection instead of delta"),
460  "element-size",
461  NULL,
462  gettext_noop ("element size"),
463  &element_size),
465  "statistics",
466  "FILENAME",
467  gettext_noop ("write statistics to file"),
470  };
471 
472  GNUNET_PROGRAM_run2 (argc, argv,
473  "gnunet-seti-profiler",
474  "help",
475  options,
476  &pre_run,
477  NULL,
478  GNUNET_YES);
479  return ret;
480 }
int GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:141
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int ret
static unsigned int num_c
static void pre_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Definition of a command line option.
static unsigned int use_intersection
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
static char * statistics_filename
The profiler will write statistics for all peers to the file with this name.
static unsigned int num_b
static unsigned int num_a
static unsigned int element_size
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Definition at line 33 of file gnunet-seti-profiler.c.

Referenced by main(), map_remove_iterator(), pre_run(), and run().

◆ num_a

unsigned int num_a = 5
static

Definition at line 35 of file gnunet-seti-profiler.c.

Referenced by main(), and run().

◆ num_b

unsigned int num_b = 5
static

Definition at line 36 of file gnunet-seti-profiler.c.

Referenced by main(), and run().

◆ num_c

unsigned int num_c = 20
static

Definition at line 37 of file gnunet-seti-profiler.c.

Referenced by main(), and run().

◆ config

const struct GNUNET_CONFIGURATION_Handle* config
static

Definition at line 39 of file gnunet-seti-profiler.c.

◆ info1

struct SetInfo info1

◆ info2

struct SetInfo info2

◆ common_sent

struct GNUNET_CONTAINER_MultiHashMap* common_sent
static

Definition at line 51 of file gnunet-seti-profiler.c.

◆ app_id

struct GNUNET_HashCode app_id
static

Definition at line 53 of file gnunet-seti-profiler.c.

Referenced by run().

◆ local_peer

struct GNUNET_PeerIdentity local_peer
static

Definition at line 55 of file gnunet-seti-profiler.c.

Referenced by run().

◆ set_listener

struct GNUNET_SETI_ListenHandle* set_listener
static

Definition at line 57 of file gnunet-seti-profiler.c.

◆ use_intersection

unsigned int use_intersection
static

Definition at line 59 of file gnunet-seti-profiler.c.

Referenced by main(), run(), and set_listen_cb().

◆ element_size

unsigned int element_size = 32
static

Definition at line 61 of file gnunet-seti-profiler.c.

Referenced by main(), run(), set_insert_iterator(), and set_result_cb().

◆ statistics

struct GNUNET_STATISTICS_Handle* statistics
static

Handle to the statistics service.

Definition at line 66 of file gnunet-seti-profiler.c.

◆ statistics_filename

char* statistics_filename
static

The profiler will write statistics for all peers to the file with this name.

Definition at line 72 of file gnunet-seti-profiler.c.

Referenced by check_all_done(), and main().

◆ statistics_file

FILE* statistics_file
static

The profiler will write statistics for all peers to this file.

Definition at line 78 of file gnunet-seti-profiler.c.

Referenced by check_all_done(), statistics_done(), and statistics_result().