aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/perf_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-19 12:05:35 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-19 12:05:35 +0000
commit33d7922f5f3ebbf4239f105b7cf030f3e3cc7733 (patch)
tree48d5708ed716b8d3b037997cdbded09e56a1d5c7 /src/ats-tests/perf_ats.c
parent656c7503c6074425e86ad0e9d4e407de21d3e73d (diff)
downloadgnunet-33d7922f5f3ebbf4239f105b7cf030f3e3cc7733.tar.gz
gnunet-33d7922f5f3ebbf4239f105b7cf030f3e3cc7733.zip
added duration cmd line argument
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r--src/ats-tests/perf_ats.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index b4ff92b95..c4689ad0c 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -30,11 +30,6 @@
30#include "gnunet_core_service.h" 30#include "gnunet_core_service.h"
31#include "perf_ats.h" 31#include "perf_ats.h"
32 32
33#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
34#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
35#define TESTNAME_PREFIX "perf_ats_"
36#define DEFAULT_SLAVES_NUM 3
37#define DEFAULT_MASTERS_NUM 1
38 33
39#define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 34#define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
40#define TEST_ATS_PREFRENCE_START 1.0 35#define TEST_ATS_PREFRENCE_START 1.0
@@ -139,7 +134,7 @@ static int num_masters;
139/** 134/**
140 * Array of master peers 135 * Array of master peers
141 */ 136 */
142struct BenchmarkPeer *mps; 137static struct BenchmarkPeer *mps;
143 138
144/** 139/**
145 * Number slave peers 140 * Number slave peers
@@ -148,7 +143,12 @@ static int num_slaves;
148/** 143/**
149 * Array of slave peers 144 * Array of slave peers
150 */ 145 */
151struct BenchmarkPeer *sps; 146static struct BenchmarkPeer *sps;
147
148/**
149 * Benchmark duration
150 */
151static struct GNUNET_TIME_Relative perf_duration;
152 152
153/** 153/**
154 * Benchmark state 154 * Benchmark state
@@ -163,7 +163,7 @@ evaluate ()
163 unsigned int duration; 163 unsigned int duration;
164 struct BenchmarkPeer *mp; 164 struct BenchmarkPeer *mp;
165 165
166 duration = (BENCHMARK_DURATION.rel_value_us / (1000 * 1000)); 166 duration = (perf_duration.rel_value_us / (1000 * 1000));
167 for (c_m = 0; c_m < num_masters; c_m++) 167 for (c_m = 0; c_m < num_masters; c_m++)
168 { 168 {
169 mp = &mps[c_m]; 169 mp = &mps[c_m];
@@ -390,7 +390,7 @@ print_progress ()
390 progress_task = GNUNET_SCHEDULER_NO_TASK; 390 progress_task = GNUNET_SCHEDULER_NO_TASK;
391 391
392 fprintf (stderr, "%llu..", 392 fprintf (stderr, "%llu..",
393 (long long unsigned) BENCHMARK_DURATION.rel_value_us / (1000 * 1000) - calls); 393 (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) - calls);
394 calls++; 394 calls++;
395 395
396 progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 396 progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
@@ -431,7 +431,7 @@ do_benchmark ()
431 431
432 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) 432 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
433 GNUNET_SCHEDULER_cancel (shutdown_task); 433 GNUNET_SCHEDULER_cancel (shutdown_task);
434 shutdown_task = GNUNET_SCHEDULER_add_delayed (BENCHMARK_DURATION, 434 shutdown_task = GNUNET_SCHEDULER_add_delayed (perf_duration,
435 &do_shutdown, NULL ); 435 &do_shutdown, NULL );
436 436
437 progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL ); 437 progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL );
@@ -1176,6 +1176,22 @@ main (int argc, char *argv[])
1176 1176
1177 for (c = 0; c < (argc - 1); c++) 1177 for (c = 0; c < (argc - 1); c++)
1178 { 1178 {
1179 if (0 == strcmp (argv[c], "-d"))
1180 break;
1181 }
1182 if (c < argc - 1)
1183 {
1184 if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &perf_duration))
1185 fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]);
1186 }
1187 else
1188 {
1189 perf_duration = BENCHMARK_DURATION;
1190 }
1191 fprintf (stderr, "Running benchmark for %llu secs\n", (unsigned long long) (perf_duration.rel_value_us) / (1000 * 1000));
1192
1193 for (c = 0; c < (argc - 1); c++)
1194 {
1179 if (0 == strcmp (argv[c], "-s")) 1195 if (0 == strcmp (argv[c], "-s"))
1180 break; 1196 break;
1181 } 1197 }