/*
This file is part of GNUnet
- Copyright (C) 2012 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2012 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
static unsigned *results_for_peer;
+/**
+ * The profiler will write statistics
+ * for all peers to the file with this name.
+ */
+static char *statistics_filename;
+
+/**
+ * The profiler will write statistics
+ * for all peers to this file.
+ */
+static FILE *statistics_file;
+
static int verbose;
/**
static void
-statistics_done_db (void *cls,
+statistics_done_cb (void *cls,
struct
GNUNET_TESTBED_Operation
*op,
{
GNUNET_assert (NULL == emsg);
GNUNET_TESTBED_operation_done (op);
- printf ("statistics done\n");
+ if (NULL != statistics_file)
+ fclose (statistics_file);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "got statistics, shutting down\n");
GNUNET_SCHEDULER_shutdown ();
}
* @param subsystem name of subsystem that created the statistic
* @param name the name of the datum
* @param value the current value
- * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
- * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
+ * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
+ * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/
static int
statistics_cb (void *cls,
uint64_t value,
int is_persistent)
{
- printf ("stat P%u: %s/%s=%lu\n", GNUNET_TESTBED_get_index (peer), subsystem, name, (unsigned long) value);
+ if (NULL != statistics_file)
+ {
+ fprintf (statistics_file, "P%u\t%s\t%s\t%lu\n", GNUNET_TESTBED_get_index (peer), subsystem, name, (unsigned long) value);
+ }
return GNUNET_OK;
}
static void
-destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *ctx)
+destroy (void *cls)
{
struct GNUNET_CONSENSUS_Handle *consensus = cls;
i,
results_for_peer[i],
num_values);
+ if (NULL != statistics_filename)
+ statistics_file = fopen (statistics_filename, "w");
GNUNET_TESTBED_get_statistics (num_peers, peers, NULL, NULL,
statistics_cb,
- statistics_done_db,
+ statistics_done_cb,
NULL);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"consensus %d done\n",
- chp - consensus_handles);
+ (int) (chp - consensus_handles));
GNUNET_SCHEDULER_add_now (destroy, *chp);
}
disconnect_adapter(void *cls, void *op_result)
{
/* FIXME: what to do here? */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "disconnect adapter called\n");
}
{ 'd', "delay", NULL,
gettext_noop ("delay until consensus starts"),
GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &consensus_delay },
+ { 's', "statistics", NULL,
+ gettext_noop ("write statistics to file"),
+ GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename },
{ 'V', "verbose", NULL,
gettext_noop ("be more verbose (print received values)"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },
options, &run, NULL, GNUNET_YES);
return 0;
}
-