Mercurial > hg > freeDiameter
changeset 575:66f188b3ca84
Configurable parameters for the benchmark mode
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 08 Oct 2010 16:02:48 +0900 |
parents | fc593a1c35bd |
children | 294c568bec00 |
files | doc/test_app.conf.sample extensions/test_app/ta_bench.c extensions/test_app/ta_conf.y extensions/test_app/ta_serv.c extensions/test_app/test_app.c extensions/test_app/test_app.h |
diffstat | 6 files changed, 36 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/test_app.conf.sample Fri Oct 08 15:35:19 2010 +0900 +++ b/doc/test_app.conf.sample Fri Oct 08 16:02:48 2010 +0900 @@ -41,7 +41,11 @@ # When this keyword appears, it changes the behavior as follow: # - server is silent on message reception, only the activity summary is displayed every 30 seconds # - client attempts to send as many messages as possible during 10 seconds and counts them. -# benchmark; +# The benchmark keyword can be followed optionaly by two integers: +# duration is the time for the measurement, in seconds (default 10). +# concurrency is the number of messages that can be on the wire before waiting for an answer (default 100). +# benchmark [duration concurrency]; + ####################### # Client-specific configuration
--- a/extensions/test_app/ta_bench.c Fri Oct 08 15:35:19 2010 +0900 +++ b/extensions/test_app/ta_bench.c Fri Oct 08 16:02:48 2010 +0900 @@ -38,10 +38,6 @@ #include "test_app.h" #include <semaphore.h> - -/* The number of messages that can be sent before waiting for a corresponding answer */ -#define NB_CONCURRENT_MESSAGES 100 - #include <stdio.h> struct ta_mess_info { @@ -49,7 +45,7 @@ struct timespec ts; /* Time of sending the message */ }; -static sem_t ta_sem; +static sem_t ta_sem; /* To handle the concurrency */ /* Cb called when an answer is received */ static void ta_cb_ans(void * data, struct msg ** msg) @@ -220,9 +216,9 @@ memcpy(&start, &ta_conf->stats, sizeof(struct ta_stats)); CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); - /* We will run for 10 seconds */ + /* We will run for ta_conf->bench_duration seconds */ CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &end_time), ); - end_time.tv_sec += 10; + end_time.tv_sec += ta_conf->bench_duration; /* Now loop until timeout is reached */ do { @@ -253,23 +249,21 @@ fd_log_debug( "------- app_test Benchmark result ---------\n"); if (now.tv_nsec >= end_time.tv_nsec) { fd_log_debug( " Executing for: %d.%06ld sec\n", - (int)(now.tv_sec + 10 - end_time.tv_sec), + (int)(now.tv_sec + ta_conf->bench_duration - end_time.tv_sec), (long)(now.tv_nsec - end_time.tv_nsec) / 1000); } else { fd_log_debug( " Executing for: %d.%06ld sec\n", - (int)(now.tv_sec + 9 - end_time.tv_sec), + (int)(now.tv_sec + ta_conf->bench_duration - 1 - end_time.tv_sec), (long)(now.tv_nsec + 1000000000 - end_time.tv_nsec) / 1000); } fd_log_debug( " %llu messages sent\n", end.nb_sent - start.nb_sent); - fd_log_debug( " %llu errors received\n", end.nb_errs - start.nb_errs); - fd_log_debug( " %llu answers received\n", end.nb_recv - start.nb_recv); + fd_log_debug( " %llu error(s) received\n", end.nb_errs - start.nb_errs); + fd_log_debug( " %llu answer(s) received\n", end.nb_recv - start.nb_recv); fd_log_debug( " Overall:\n"); fd_log_debug( " fastest: %ld.%06ld sec.\n", end.shortest / 1000000, end.shortest % 1000000); fd_log_debug( " slowest: %ld.%06ld sec.\n", end.longest / 1000000, end.longest % 1000000); fd_log_debug( " Average: %ld.%06ld sec.\n", end.avg / 1000000, end.avg % 1000000); - fd_log_debug( " Throughput: %llu message / sec\n", (end.nb_recv - start.nb_recv) / (( now.tv_sec + 10 - end_time.tv_sec ) + ((now.tv_nsec - end_time.tv_nsec) / 1000000000))); - - + fd_log_debug( " Throughput: %llu messages / sec\n", (end.nb_recv - start.nb_recv) / (( now.tv_sec + ta_conf->bench_duration - end_time.tv_sec ) + ((now.tv_nsec - end_time.tv_nsec) / 1000000000))); fd_log_debug( "-------------------------------------\n"); } @@ -277,7 +271,7 @@ int ta_bench_init(void) { - CHECK_SYS( sem_init( &ta_sem, 0, NB_CONCURRENT_MESSAGES) ); + CHECK_SYS( sem_init( &ta_sem, 0, ta_conf->bench_concur) ); CHECK_FCT( fd_sig_register(ta_conf->signal, "test_app.bench", ta_bench_start ) );
--- a/extensions/test_app/ta_conf.y Fri Oct 08 15:35:19 2010 +0900 +++ b/extensions/test_app/ta_conf.y Fri Oct 08 16:02:48 2010 +0900 @@ -187,6 +187,12 @@ { ta_conf->mode |= MODE_BENCH; } + | BENCH INTEGER INTEGER ';' + { + ta_conf->mode |= MODE_BENCH; + ta_conf->bench_duration = $2; + ta_conf->bench_concur = $3; + } ; dstrealm: DEST_REALM '=' QSTRING ';'
--- a/extensions/test_app/ta_serv.c Fri Oct 08 15:35:19 2010 +0900 +++ b/extensions/test_app/ta_serv.c Fri Oct 08 16:02:48 2010 +0900 @@ -100,6 +100,11 @@ /* Send the answer */ CHECK_FCT( fd_msg_send( msg, NULL, NULL ) ); + /* Add this value to the stats */ + CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), ); + ta_conf->stats.nb_echoed++; + CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); + return 0; }
--- a/extensions/test_app/test_app.c Fri Oct 08 15:35:19 2010 +0900 +++ b/extensions/test_app/test_app.c Fri Oct 08 16:02:48 2010 +0900 @@ -58,6 +58,8 @@ ta_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm); ta_conf->dest_host = NULL; ta_conf->signal = TEST_APP_DEFAULT_SIGNAL; + ta_conf->bench_concur = 100; + ta_conf->bench_duration = 10; /* Initialize the mutex */ CHECK_POSIX( pthread_mutex_init(&ta_conf->stats_lock, NULL) ); @@ -81,7 +83,7 @@ fd_log_debug( "------- /app_test configuration dump ---------\n"); } -/* Function to display statistics every 10 seconds */ +/* Function to display statistics periodically */ static void * ta_stats(void * arg) { struct timespec start, now; @@ -92,8 +94,8 @@ /* Now, loop until canceled */ while (1) { - /* Display statistics every 30 seconds */ - sleep(30); + /* Display statistics every XX seconds */ + sleep(ta_conf->bench_duration * 3); /* Now, get the current stats */ CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), ); @@ -116,13 +118,13 @@ } if (ta_conf->mode & MODE_SERV) { - fd_log_debug( " Server: %llu messages echoed\n", copy.nb_echoed); + fd_log_debug( " Server: %llu message(s) echoed\n", copy.nb_echoed); } if (ta_conf->mode & MODE_CLI) { fd_log_debug( " Client:\n"); - fd_log_debug( " %llu messages sent\n", copy.nb_sent); - fd_log_debug( " %llu errors received\n", copy.nb_errs); - fd_log_debug( " %llu answers received\n", copy.nb_recv); + fd_log_debug( " %llu message(s) sent\n", copy.nb_sent); + fd_log_debug( " %llu error(s) received\n", copy.nb_errs); + fd_log_debug( " %llu answer(s) received\n", copy.nb_recv); fd_log_debug( " fastest: %ld.%06ld sec.\n", copy.shortest / 1000000, copy.shortest % 1000000); fd_log_debug( " slowest: %ld.%06ld sec.\n", copy.longest / 1000000, copy.longest % 1000000); fd_log_debug( " Average: %ld.%06ld sec.\n", copy.avg / 1000000, copy.avg % 1000000);
--- a/extensions/test_app/test_app.h Fri Oct 08 15:35:19 2010 +0900 +++ b/extensions/test_app/test_app.h Fri Oct 08 16:02:48 2010 +0900 @@ -64,6 +64,8 @@ char * dest_host; /* default NULL */ char * user_name; /* default NULL */ int signal; /* default TEST_APP_DEFAULT_SIGNAL */ + int bench_concur; /* default 100 */ + int bench_duration; /* default 10 */ struct ta_stats { unsigned long long nb_echoed; /* server */ unsigned long long nb_sent; /* client */