#include "gnunet_core_service.h"
#include "perf_ats.h"
-#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
-#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-#define TESTNAME_PREFIX "perf_ats_"
-#define DEFAULT_SLAVES_NUM 3
-#define DEFAULT_MASTERS_NUM 1
#define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
#define TEST_ATS_PREFRENCE_START 1.0
/**
* Array of master peers
*/
-struct BenchmarkPeer *mps;
+static struct BenchmarkPeer *mps;
/**
* Number slave peers
/**
* Array of slave peers
*/
-struct BenchmarkPeer *sps;
+static struct BenchmarkPeer *sps;
+
+/**
+ * Benchmark duration
+ */
+static struct GNUNET_TIME_Relative perf_duration;
+
+/**
+ * Logging frequency
+ */
+static struct GNUNET_TIME_Relative log_frequency;
/**
* Benchmark state
unsigned int duration;
struct BenchmarkPeer *mp;
- duration = (BENCHMARK_DURATION.rel_value_us / (1000 * 1000));
+ duration = (perf_duration.rel_value_us / (1000 * 1000));
for (c_m = 0; c_m < num_masters; c_m++)
{
mp = &mps[c_m];
else
p->tth = NULL;
+ if (NULL == buf)
+ {
+ GNUNET_break (0);
+ return 0;
+ }
+ if (size < TEST_MESSAGE_SIZE)
+ {
+ GNUNET_break (0);
+ return 0;
+ }
+
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n",
p->me->no, p->dest->no);
return TEST_MESSAGE_SIZE;
}
+static void
+comm_schedule_send (struct BenchmarkPartner *p)
+{
+ if (GNUNET_YES == test_core)
+ {
+ p->cth = GNUNET_CORE_notify_transmit_ready (
+ p->me->ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &p->dest->id,
+ TEST_MESSAGE_SIZE, &comm_send_ready, p);
+ }
+ else
+ {
+ p->tth = GNUNET_TRANSPORT_notify_transmit_ready (
+ p->me->th, &p->dest->id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES,
+ &comm_send_ready, p);
+ }
+
+}
+
static void
print_progress ()
{
progress_task = GNUNET_SCHEDULER_NO_TASK;
fprintf (stderr, "%llu..",
- (long long unsigned) BENCHMARK_DURATION.rel_value_us / (1000 * 1000) - calls);
+ (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) - calls);
calls++;
progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_add_delayed (BENCHMARK_DURATION,
+ shutdown_task = GNUNET_SCHEDULER_add_delayed (perf_duration,
&do_shutdown, NULL );
progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL );
for (c_m = 0; c_m < num_masters; c_m++)
{
for (c_s = 0; c_s < num_slaves; c_s++)
- {
- if (GNUNET_YES == test_core)
- mps[c_m].partners[c_s].cth = GNUNET_CORE_notify_transmit_ready (
- mps[c_m].ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &sps[c_s].id,
- TEST_MESSAGE_SIZE, &comm_send_ready, &mps[c_m].partners[c_s]);
- else
- {
- mps[c_m].partners[c_s].tth = GNUNET_TRANSPORT_notify_transmit_ready (
- mps[c_m].th, &sps[c_s].id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES,
- &comm_send_ready, &mps[c_m].partners[c_s]);
- }
- }
+ comm_schedule_send (&mps[c_m].partners[c_s]);
if (pref_val != GNUNET_ATS_PREFERENCE_END)
mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &mps[c_m]);
}
if (GNUNET_YES == logging)
- perf_logging_start (testname, mps, num_masters);
+ perf_logging_start (log_frequency, testname, mps, num_masters);
}
p->me->total_messages_received++;
p->me->total_bytes_received += TEST_MESSAGE_SIZE;
- if (GNUNET_YES == test_core)
- {
- GNUNET_assert (NULL == p->cth);
- p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
- GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
- &comm_send_ready, p);
- }
- else
- {
- GNUNET_assert (NULL == p->tth);
- p->tth = GNUNET_TRANSPORT_notify_transmit_ready (
- me->th, &p->dest->id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES,
- &comm_send_ready, p);
- }
-
+ comm_schedule_send (p);
return GNUNET_OK;
}
return -1;
}
+ for (c = 0; c < (argc - 1); c++)
+ {
+ if (0 == strcmp (argv[c], "-d"))
+ break;
+ }
+ if (c < argc - 1)
+ {
+ if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &perf_duration))
+ fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]);
+ }
+ else
+ {
+ perf_duration = BENCHMARK_DURATION;
+ }
+ fprintf (stderr, "Running benchmark for %llu secs\n", (unsigned long long) (perf_duration.rel_value_us) / (1000 * 1000));
+
for (c = 0; c < (argc - 1); c++)
{
if (0 == strcmp (argv[c], "-s"))
logging = GNUNET_YES;
}
+ if (GNUNET_YES == logging)
+ {
+ for (c = 0; c < (argc - 1); c++)
+ {
+ if (0 == strcmp (argv[c], "-f"))
+ break;
+ }
+ if (c < argc - 1)
+ {
+ if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &log_frequency))
+ fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]);
+ }
+ else
+ {
+ log_frequency = LOGGING_FREQUENCY;
+ }
+ fprintf (stderr, "Using log frequency %llu ms\n",
+ (unsigned long long) (log_frequency.rel_value_us) / (1000));
+ }
+
GNUNET_asprintf (&testname, "%s_%s_%s",solver, comm_name, pref_str);
if (num_slaves < num_masters)