aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/gnunet-consensus-profiler.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-12-09 14:58:08 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-12-09 14:58:08 +0000
commitff83e00aa65129b78627ad994d772b651872d1c1 (patch)
tree5947e0325689c9f3041448d94a7eff46df3129fb /src/consensus/gnunet-consensus-profiler.c
parent36b0e18395e097759f51908a05888a3da6751643 (diff)
downloadgnunet-ff83e00aa65129b78627ad994d772b651872d1c1.tar.gz
gnunet-ff83e00aa65129b78627ad994d772b651872d1c1.zip
Statistics log file for consensus profiler.
Diffstat (limited to 'src/consensus/gnunet-consensus-profiler.c')
-rw-r--r--src/consensus/gnunet-consensus-profiler.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/consensus/gnunet-consensus-profiler.c b/src/consensus/gnunet-consensus-profiler.c
index 143264f21..077ab57b5 100644
--- a/src/consensus/gnunet-consensus-profiler.c
+++ b/src/consensus/gnunet-consensus-profiler.c
@@ -57,6 +57,10 @@ static unsigned int peers_done = 0;
57 57
58static unsigned *results_for_peer; 58static unsigned *results_for_peer;
59 59
60static char *statistics_filename;
61
62static FILE *statistics_file;
63
60static int verbose; 64static int verbose;
61 65
62/** 66/**
@@ -94,7 +98,8 @@ statistics_done_db (void *cls,
94{ 98{
95 GNUNET_assert (NULL == emsg); 99 GNUNET_assert (NULL == emsg);
96 GNUNET_TESTBED_operation_done (op); 100 GNUNET_TESTBED_operation_done (op);
97 printf ("statistics done\n"); 101 if (NULL != statistics_file)
102 fclose (statistics_file);
98 GNUNET_SCHEDULER_shutdown (); 103 GNUNET_SCHEDULER_shutdown ();
99} 104}
100 105
@@ -118,7 +123,10 @@ statistics_cb (void *cls,
118 uint64_t value, 123 uint64_t value,
119 int is_persistent) 124 int is_persistent)
120{ 125{
121 printf ("stat P%u: %s/%s=%lu\n", GNUNET_TESTBED_get_index (peer), subsystem, name, (unsigned long) value); 126 if (NULL != statistics_file)
127 {
128 fprintf (statistics_file, "P%u\t%s\t%s\t%lu\n", GNUNET_TESTBED_get_index (peer), subsystem, name, (unsigned long) value);
129 }
122 return GNUNET_OK; 130 return GNUNET_OK;
123} 131}
124 132
@@ -142,6 +150,8 @@ destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *ctx)
142 i, 150 i,
143 results_for_peer[i], 151 results_for_peer[i],
144 num_values); 152 num_values);
153 if (NULL != statistics_filename)
154 statistics_file = fopen (statistics_filename, "w");
145 GNUNET_TESTBED_get_statistics (num_peers, peers, NULL, NULL, 155 GNUNET_TESTBED_get_statistics (num_peers, peers, NULL, NULL,
146 statistics_cb, 156 statistics_cb,
147 statistics_done_db, 157 statistics_done_db,
@@ -489,6 +499,9 @@ main (int argc, char **argv)
489 { 'd', "delay", NULL, 499 { 'd', "delay", NULL,
490 gettext_noop ("delay until consensus starts"), 500 gettext_noop ("delay until consensus starts"),
491 GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &consensus_delay }, 501 GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &consensus_delay },
502 { 's', "statistics", NULL,
503 gettext_noop ("write statistics to file"),
504 GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename },
492 { 'V', "verbose", NULL, 505 { 'V', "verbose", NULL,
493 gettext_noop ("be more verbose (print received values)"), 506 gettext_noop ("be more verbose (print received values)"),
494 GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose }, 507 GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },