# HG changeset patch # User Sebastien Decugis # Date 1370930733 -28800 # Node ID 16f2d2f15e5bf832939ef2f5822b5a6d023aae7e # Parent 90d1222a65a811f8f7804bdbcb23ab253ce2dde4 Allow better usage in benchmark mode diff -r 90d1222a65a8 -r 16f2d2f15e5b extensions/test_app/ta_bench.c --- a/extensions/test_app/ta_bench.c Tue Jun 11 14:04:40 2013 +0800 +++ b/extensions/test_app/ta_bench.c Tue Jun 11 14:05:33 2013 +0800 @@ -205,6 +205,7 @@ CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); /* We will run for ta_conf->bench_duration seconds */ + LOG_N("Starting benchmark client, %ds", ta_conf->bench_duration); CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &end_time), ); end_time.tv_sec += ta_conf->bench_duration; @@ -235,25 +236,25 @@ CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); /* Now, display the statistics */ - fd_log_debug( "------- app_test Benchmark result ---------"); + LOG_N( "------- app_test Benchmark result ---------"); if (now.tv_nsec >= end_time.tv_nsec) { - fd_log_debug( " Executing for: %d.%06ld sec", + LOG_N( " Executing for: %d.%06ld 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", + LOG_N( " Executing for: %d.%06ld 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", end.nb_sent - start.nb_sent); - fd_log_debug( " %llu error(s) received", end.nb_errs - start.nb_errs); - fd_log_debug( " %llu answer(s) received", end.nb_recv - start.nb_recv); - fd_log_debug( " Overall:"); - fd_log_debug( " fastest: %ld.%06ld sec.", end.shortest / 1000000, end.shortest % 1000000); - fd_log_debug( " slowest: %ld.%06ld sec.", end.longest / 1000000, end.longest % 1000000); - fd_log_debug( " Average: %ld.%06ld sec.", end.avg / 1000000, end.avg % 1000000); - fd_log_debug( " Throughput: %llu messages / sec", (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( "-------------------------------------"); + LOG_N( " %llu messages sent", end.nb_sent - start.nb_sent); + LOG_N( " %llu error(s) received", end.nb_errs - start.nb_errs); + LOG_N( " %llu answer(s) received", end.nb_recv - start.nb_recv); + LOG_N( " Overall:"); + LOG_N( " fastest: %ld.%06ld sec.", end.shortest / 1000000, end.shortest % 1000000); + LOG_N( " slowest: %ld.%06ld sec.", end.longest / 1000000, end.longest % 1000000); + LOG_N( " Average: %ld.%06ld sec.", end.avg / 1000000, end.avg % 1000000); + LOG_N( " Throughput: %llu messages / sec", (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))); + LOG_N( "-------------------------------------"); } diff -r 90d1222a65a8 -r 16f2d2f15e5b extensions/test_app/test_app.c --- a/extensions/test_app/test_app.c Tue Jun 11 14:04:40 2013 +0800 +++ b/extensions/test_app/test_app.c Tue Jun 11 14:05:33 2013 +0800 @@ -43,6 +43,7 @@ struct ta_conf * ta_conf = NULL; static struct ta_conf _conf; static pthread_t ta_stats_th = (pthread_t)NULL; +static struct fd_hook_hdl * hookhdl = NULL; static int ta_conf_init(void) { @@ -95,7 +96,7 @@ /* Now, loop until canceled */ while (1) { /* Display statistics every XX seconds */ - sleep(ta_conf->bench_duration * 3); + sleep(ta_conf->bench_duration + 3); /* Now, get the current stats */ CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), ); @@ -135,6 +136,11 @@ return NULL; /* never called */ } +static void ta_hook_cb(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) { + +} + + /* entry point */ static int ta_entry(char * conffile) { @@ -171,6 +177,13 @@ /* Advertise the support for the test application in the peer */ CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) ); + if (ta_conf->mode & MODE_BENCH) { + /* Register an empty hook to disable the default handling */ + CHECK_FCT( fd_hook_register( (1<mode & MODE_SERV) ta_serv_fini(); + if (hookhdl) + fd_hook_unregister( hookhdl ); CHECK_FCT_DO( fd_thr_term(&ta_stats_th), ); CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), ); }