diff options
author | Julius Bünger <buenger@mytum.de> | 2018-07-10 12:13:14 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-07-10 12:13:14 +0200 |
commit | d1c8a1e764430a7720bc2962414aa45e1d3b9030 (patch) | |
tree | 453f3d90db1817286409f672af126887a7357c9b /src/rps/gnunet-rps-profiler.c | |
parent | 857f3bc73618d69cd1122a8a519c89a46aee037b (diff) | |
download | gnunet-d1c8a1e764430a7720bc2962414aa45e1d3b9030.tar.gz gnunet-d1c8a1e764430a7720bc2962414aa45e1d3b9030.zip |
rps profiler: add option for duration of profiling
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 9ad6d3c3b..cab7f6dc4 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -49,7 +49,11 @@ static unsigned bits_needed; | |||
49 | /** | 49 | /** |
50 | * How long do we run the test? | 50 | * How long do we run the test? |
51 | */ | 51 | */ |
52 | //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 52 | static struct GNUNET_TIME_Relative duration; |
53 | |||
54 | /** | ||
55 | * When do we do a hard shutdown? | ||
56 | */ | ||
53 | static struct GNUNET_TIME_Relative timeout; | 57 | static struct GNUNET_TIME_Relative timeout; |
54 | 58 | ||
55 | 59 | ||
@@ -995,7 +999,7 @@ shutdown_op (void *cls) | |||
995 | 999 | ||
996 | 1000 | ||
997 | /** | 1001 | /** |
998 | * Task run on timeout to collect statistics and potentially shut down. | 1002 | * Task run after #duration to collect statistics and potentially shut down. |
999 | */ | 1003 | */ |
1000 | static void | 1004 | static void |
1001 | post_test_op (void *cls) | 1005 | post_test_op (void *cls) |
@@ -1314,7 +1318,8 @@ default_reply_handle (void *cls, | |||
1314 | 1318 | ||
1315 | if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) | 1319 | if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) |
1316 | { | 1320 | { |
1317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); | 1321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1322 | "Test succeeded before end of duration\n"); | ||
1318 | GNUNET_assert (NULL != post_test_task); | 1323 | GNUNET_assert (NULL != post_test_task); |
1319 | GNUNET_SCHEDULER_cancel (post_test_task); | 1324 | GNUNET_SCHEDULER_cancel (post_test_task); |
1320 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); | 1325 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); |
@@ -2629,11 +2634,9 @@ test_run (void *cls, | |||
2629 | 2634 | ||
2630 | if (NULL != churn_task) | 2635 | if (NULL != churn_task) |
2631 | GNUNET_SCHEDULER_cancel (churn_task); | 2636 | GNUNET_SCHEDULER_cancel (churn_task); |
2632 | post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL); | 2637 | post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL); |
2633 | timeout = GNUNET_TIME_relative_multiply (timeout, 1.2 + (0.01 * num_peers)); | 2638 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", timeout.rel_value_us/1000000); |
2634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for hard shutdown is %lu\n", timeout.rel_value_us/1000000); | ||
2635 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 2639 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
2636 | |||
2637 | } | 2640 | } |
2638 | 2641 | ||
2639 | 2642 | ||
@@ -2669,7 +2672,7 @@ run (void *cls, | |||
2669 | if (0 == cur_test_run.num_requests) cur_test_run.num_requests = 5; | 2672 | if (0 == cur_test_run.num_requests) cur_test_run.num_requests = 5; |
2670 | //cur_test_run.have_churn = HAVE_CHURN; | 2673 | //cur_test_run.have_churn = HAVE_CHURN; |
2671 | cur_test_run.have_churn = HAVE_NO_CHURN; | 2674 | cur_test_run.have_churn = HAVE_NO_CHURN; |
2672 | cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; | 2675 | cur_test_run.have_quick_quit = HAVE_QUICK_QUIT; |
2673 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; | 2676 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; |
2674 | cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) | | 2677 | cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) | |
2675 | BIT(STAT_TYPE_BLOCKS) | | 2678 | BIT(STAT_TYPE_BLOCKS) | |
@@ -2692,9 +2695,30 @@ run (void *cls, | |||
2692 | /* 'Clean' directory */ | 2695 | /* 'Clean' directory */ |
2693 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); | 2696 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); |
2694 | GNUNET_DISK_directory_create ("/tmp/rps/"); | 2697 | GNUNET_DISK_directory_create ("/tmp/rps/"); |
2695 | if (0 == timeout.rel_value_us) | 2698 | if (0 == duration.rel_value_us) |
2696 | { | 2699 | { |
2697 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | 2700 | if (0 == timeout.rel_value_us) |
2701 | { | ||
2702 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | ||
2703 | timeout = GNUNET_TIME_relative_multiply (duration, | ||
2704 | 1.2 + (0.01 * num_peers)); | ||
2705 | } | ||
2706 | else | ||
2707 | { | ||
2708 | duration = GNUNET_TIME_relative_multiply (timeout, 0.75 ); | ||
2709 | } | ||
2710 | } | ||
2711 | else | ||
2712 | { | ||
2713 | if (0 == timeout.rel_value_us) | ||
2714 | { | ||
2715 | timeout = GNUNET_TIME_relative_multiply (duration, | ||
2716 | 1.2 + (0.01 * num_peers)); | ||
2717 | } | ||
2718 | else | ||
2719 | { | ||
2720 | GNUNET_assert (duration.rel_value_us <= timeout.rel_value_us); | ||
2721 | } | ||
2698 | } | 2722 | } |
2699 | 2723 | ||
2700 | /* Compute number of bits for representing largest peer id */ | 2724 | /* Compute number of bits for representing largest peer id */ |
@@ -2745,6 +2769,12 @@ main (int argc, char *argv[]) | |||
2745 | gettext_noop ("number of peers to start"), | 2769 | gettext_noop ("number of peers to start"), |
2746 | &num_peers), | 2770 | &num_peers), |
2747 | 2771 | ||
2772 | GNUNET_GETOPT_option_relative_time ('d', | ||
2773 | "duration", | ||
2774 | "DURATION", | ||
2775 | gettext_noop ("duration of the profiling"), | ||
2776 | &duration), | ||
2777 | |||
2748 | GNUNET_GETOPT_option_relative_time ('t', | 2778 | GNUNET_GETOPT_option_relative_time ('t', |
2749 | "timeout", | 2779 | "timeout", |
2750 | "TIMEOUT", | 2780 | "TIMEOUT", |