diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-04-18 18:23:17 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-04-18 18:23:17 +0000 |
commit | 346667d235fb8dbf34454515a9f5d27efbe1db37 (patch) | |
tree | f6cd1ee1b8c7c88b667f572dd98658f49dd14fc0 /src/regex | |
parent | 3b691360358390bee96bf66568b4416e41c33d59 (diff) | |
download | gnunet-346667d235fb8dbf34454515a9f5d27efbe1db37.tar.gz gnunet-346667d235fb8dbf34454515a9f5d27efbe1db37.zip |
- change profiler cmd interface
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index c0433230e..380467be1 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -251,11 +251,6 @@ static struct GNUNET_TIME_Relative prof_time; | |||
251 | static unsigned int num_peers; | 251 | static unsigned int num_peers; |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Factor of number of links. num_links = num_peers * linking_factor. | ||
255 | */ | ||
256 | static unsigned int linking_factor; | ||
257 | |||
258 | /** | ||
259 | * Global testing status | 254 | * Global testing status |
260 | */ | 255 | */ |
261 | static int result; | 256 | static int result; |
@@ -271,6 +266,16 @@ enum State state; | |||
271 | static char * policy_dir; | 266 | static char * policy_dir; |
272 | 267 | ||
273 | /** | 268 | /** |
269 | * File with hostnames where to execute the test. | ||
270 | */ | ||
271 | static char *hosts_file; | ||
272 | |||
273 | /** | ||
274 | * File with the strings to look for. | ||
275 | */ | ||
276 | static char *strings_file; | ||
277 | |||
278 | /** | ||
274 | * Search strings. | 279 | * Search strings. |
275 | */ | 280 | */ |
276 | static char **search_strings; | 281 | static char **search_strings; |
@@ -306,12 +311,6 @@ static GNUNET_SCHEDULER_TaskIdentifier search_timeout_task; | |||
306 | static struct GNUNET_TIME_Relative search_timeout_time = { 60000 }; | 311 | static struct GNUNET_TIME_Relative search_timeout_time = { 60000 }; |
307 | 312 | ||
308 | /** | 313 | /** |
309 | * How long do we wait before starting the search? | ||
310 | * Default: 1 m. | ||
311 | */ | ||
312 | static struct GNUNET_TIME_Relative search_delay = { 60000 }; | ||
313 | |||
314 | /** | ||
315 | * File to log statistics to. | 314 | * File to log statistics to. |
316 | */ | 315 | */ |
317 | static struct GNUNET_DISK_FileHandle *data_file; | 316 | static struct GNUNET_DISK_FileHandle *data_file; |
@@ -322,11 +321,6 @@ static struct GNUNET_DISK_FileHandle *data_file; | |||
322 | static char *data_filename; | 321 | static char *data_filename; |
323 | 322 | ||
324 | /** | 323 | /** |
325 | * Maximal path compression length. | ||
326 | */ | ||
327 | static unsigned int max_path_compression; | ||
328 | |||
329 | /** | ||
330 | * Prefix used for regex announcing. We need to prefix the search | 324 | * Prefix used for regex announcing. We need to prefix the search |
331 | * strings with it, in order to find something. | 325 | * strings with it, in order to find something. |
332 | */ | 326 | */ |
@@ -1120,6 +1114,8 @@ test_master (void *cls, | |||
1120 | { | 1114 | { |
1121 | unsigned int i; | 1115 | unsigned int i; |
1122 | 1116 | ||
1117 | GNUNET_assert (num_peers_ == num_peers); | ||
1118 | |||
1123 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 1119 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
1124 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1120 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1125 | "Testbed started in %s\n", | 1121 | "Testbed started in %s\n", |
@@ -1133,6 +1129,7 @@ test_master (void *cls, | |||
1133 | 1129 | ||
1134 | for (i = 0; i < num_peers; i++) | 1130 | for (i = 0; i < num_peers; i++) |
1135 | { | 1131 | { |
1132 | peers[i].peer_handle = testbed_peers[i]; | ||
1136 | } | 1133 | } |
1137 | GNUNET_SCHEDULER_add_now (&do_announce, NULL); | 1134 | GNUNET_SCHEDULER_add_now (&do_announce, NULL); |
1138 | } | 1135 | } |
@@ -1229,8 +1226,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1229 | { | 1226 | { |
1230 | unsigned int nsearchstrs; | 1227 | unsigned int nsearchstrs; |
1231 | unsigned int i; | 1228 | unsigned int i; |
1232 | char *hosts_file; | ||
1233 | char *strings_file; | ||
1234 | 1229 | ||
1235 | /* Check config */ | 1230 | /* Check config */ |
1236 | if (NULL == config) | 1231 | if (NULL == config) |
@@ -1263,14 +1258,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1263 | } | 1258 | } |
1264 | 1259 | ||
1265 | /* Check arguments */ | 1260 | /* Check arguments */ |
1266 | hosts_file = args[0]; | ||
1267 | if (NULL == hosts_file) | 1261 | if (NULL == hosts_file) |
1268 | { | 1262 | { |
1269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1263 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1270 | _("No hosts-file specified on command line. Exiting.\n")); | 1264 | _("No hosts-file specified on command line. Exiting.\n")); |
1271 | return; | 1265 | return; |
1272 | } | 1266 | } |
1273 | policy_dir = args[1]; | ||
1274 | if (NULL == policy_dir) | 1267 | if (NULL == policy_dir) |
1275 | { | 1268 | { |
1276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1291,7 +1284,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1291 | policy_dir); | 1284 | policy_dir); |
1292 | return; | 1285 | return; |
1293 | } | 1286 | } |
1294 | strings_file = args[2]; | 1287 | GNUNET_CONFIGURATION_set_value_string (cfg, "REGEXPROFILER", |
1288 | "POLICY_DIR", policy_dir); | ||
1295 | if (GNUNET_YES != GNUNET_DISK_file_test (strings_file)) | 1289 | if (GNUNET_YES != GNUNET_DISK_file_test (strings_file)) |
1296 | { | 1290 | { |
1297 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1360,6 +1354,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1360 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | 1354 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); |
1361 | event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);*/ | 1355 | event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);*/ |
1362 | prof_start_time = GNUNET_TIME_absolute_get (); | 1356 | prof_start_time = GNUNET_TIME_absolute_get (); |
1357 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "1.\n"); | ||
1363 | GNUNET_TESTBED_run (args[0], | 1358 | GNUNET_TESTBED_run (args[0], |
1364 | cfg, | 1359 | cfg, |
1365 | num_peers, | 1360 | num_peers, |
@@ -1368,11 +1363,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1368 | NULL, /* master_controller_cb cls */ | 1363 | NULL, /* master_controller_cb cls */ |
1369 | &test_master, | 1364 | &test_master, |
1370 | NULL); /* test_master cls */ | 1365 | NULL); /* test_master cls */ |
1366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "2.\n"); | ||
1371 | abort_task = | 1367 | abort_task = |
1372 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1368 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1373 | (GNUNET_TIME_UNIT_MINUTES, 5), | 1369 | (GNUNET_TIME_UNIT_MINUTES, 5), |
1374 | &do_abort, | 1370 | &do_abort, |
1375 | (void*) __LINE__); | 1371 | (void*) __LINE__); |
1372 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "3.\n"); | ||
1376 | } | 1373 | } |
1377 | 1374 | ||
1378 | 1375 | ||
@@ -1387,39 +1384,36 @@ int | |||
1387 | main (int argc, char *const *argv) | 1384 | main (int argc, char *const *argv) |
1388 | { | 1385 | { |
1389 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1386 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
1390 | {'d', "details", "FILENAME", | 1387 | {'l', "log-file", "FILENAME", |
1391 | gettext_noop ("name of the file for writing statistics"), | 1388 | gettext_noop ("name of the file for writing statistics"), |
1392 | 1, &GNUNET_GETOPT_set_string, &data_filename}, | 1389 | 1, &GNUNET_GETOPT_set_string, &data_filename}, |
1393 | {'n', "num-links", "COUNT", | ||
1394 | gettext_noop ("create COUNT number of random links between peers"), | ||
1395 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &linking_factor }, | ||
1396 | {'t', "matching-timeout", "TIMEOUT", | 1390 | {'t', "matching-timeout", "TIMEOUT", |
1397 | gettext_noop ("wait TIMEOUT before considering a string match as failed"), | 1391 | gettext_noop ("wait TIMEOUT before considering a string match as failed"), |
1398 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout_time | 1392 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout_time }, |
1399 | }, | 1393 | {'n', "num-search-strings", "COUNT", |
1400 | {'s', "search-delay", "DELAY", | ||
1401 | gettext_noop ("wait DELAY before starting string search"), | ||
1402 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_delay }, | ||
1403 | {'a', "num-search-strings", "COUNT", | ||
1404 | gettext_noop ("number of search strings to read from search strings file"), | 1394 | gettext_noop ("number of search strings to read from search strings file"), |
1405 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_search_strings }, | 1395 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_search_strings }, |
1406 | {'p', "max-path-compression", "MAX_PATH_COMPRESSION", | 1396 | {'p', "policy-dir", "DIRECTORY", |
1407 | gettext_noop ("maximum path compression length"), | 1397 | gettext_noop ("directory with policy files"), |
1408 | 1, &GNUNET_GETOPT_set_uint, &max_path_compression}, | 1398 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &policy_dir }, |
1399 | {'s', "strings-file", "FILENAME", | ||
1400 | gettext_noop ("name of file with input strings"), | ||
1401 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &strings_file }, | ||
1402 | {'H', "hosts-file", "FILENAME", | ||
1403 | gettext_noop ("name of file with hosts' names"), | ||
1404 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &hosts_file }, | ||
1409 | GNUNET_GETOPT_OPTION_END | 1405 | GNUNET_GETOPT_OPTION_END |
1410 | }; | 1406 | }; |
1411 | int ret; | 1407 | int ret; |
1412 | 1408 | ||
1413 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 1409 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
1414 | return 2; | 1410 | return 2; |
1415 | |||
1416 | result = GNUNET_SYSERR; | 1411 | result = GNUNET_SYSERR; |
1417 | ret = | 1412 | ret = |
1418 | GNUNET_PROGRAM_run (argc, argv, | 1413 | GNUNET_PROGRAM_run (argc, argv, |
1419 | "gnunet-regex-profiler [OPTIONS] hosts-file policy-dir search-strings-file", | 1414 | "gnunet-regex-profiler [OPTIONS] hosts-file policy-dir search-strings-file", |
1420 | _("Profiler for regex"), | 1415 | _("Profiler for regex"), |
1421 | options, &run, NULL); | 1416 | options, &run, NULL); |
1422 | |||
1423 | if (GNUNET_OK != ret) | 1417 | if (GNUNET_OK != ret) |
1424 | return ret; | 1418 | return ret; |
1425 | if (GNUNET_OK != result) | 1419 | if (GNUNET_OK != result) |