Changeset 1195:16f2d2f15e5b in freeDiameter for extensions
- Timestamp:
- Jun 11, 2013, 3:05:33 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- extensions/test_app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/test_app/ta_bench.c
r974 r1195 206 206 207 207 /* We will run for ta_conf->bench_duration seconds */ 208 LOG_N("Starting benchmark client, %ds", ta_conf->bench_duration); 208 209 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &end_time), ); 209 210 end_time.tv_sec += ta_conf->bench_duration; … … 236 237 237 238 /* Now, display the statistics */ 238 fd_log_debug( "------- app_test Benchmark result ---------");239 LOG_N( "------- app_test Benchmark result ---------"); 239 240 if (now.tv_nsec >= end_time.tv_nsec) { 240 fd_log_debug( " Executing for: %d.%06ld sec",241 LOG_N( " Executing for: %d.%06ld sec", 241 242 (int)(now.tv_sec + ta_conf->bench_duration - end_time.tv_sec), 242 243 (long)(now.tv_nsec - end_time.tv_nsec) / 1000); 243 244 } else { 244 fd_log_debug( " Executing for: %d.%06ld sec",245 LOG_N( " Executing for: %d.%06ld sec", 245 246 (int)(now.tv_sec + ta_conf->bench_duration - 1 - end_time.tv_sec), 246 247 (long)(now.tv_nsec + 1000000000 - end_time.tv_nsec) / 1000); 247 248 } 248 fd_log_debug( " %llu messages sent", end.nb_sent - start.nb_sent);249 fd_log_debug( " %llu error(s) received", end.nb_errs - start.nb_errs);250 fd_log_debug( " %llu answer(s) received", end.nb_recv - start.nb_recv);251 fd_log_debug( " Overall:");252 fd_log_debug( " fastest: %ld.%06ld sec.", end.shortest / 1000000, end.shortest % 1000000);253 fd_log_debug( " slowest: %ld.%06ld sec.", end.longest / 1000000, end.longest % 1000000);254 fd_log_debug( " Average: %ld.%06ld sec.", end.avg / 1000000, end.avg % 1000000);255 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)));256 fd_log_debug( "-------------------------------------");249 LOG_N( " %llu messages sent", end.nb_sent - start.nb_sent); 250 LOG_N( " %llu error(s) received", end.nb_errs - start.nb_errs); 251 LOG_N( " %llu answer(s) received", end.nb_recv - start.nb_recv); 252 LOG_N( " Overall:"); 253 LOG_N( " fastest: %ld.%06ld sec.", end.shortest / 1000000, end.shortest % 1000000); 254 LOG_N( " slowest: %ld.%06ld sec.", end.longest / 1000000, end.longest % 1000000); 255 LOG_N( " Average: %ld.%06ld sec.", end.avg / 1000000, end.avg % 1000000); 256 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))); 257 LOG_N( "-------------------------------------"); 257 258 258 259 } -
extensions/test_app/test_app.c
r1127 r1195 44 44 static struct ta_conf _conf; 45 45 static pthread_t ta_stats_th = (pthread_t)NULL; 46 static struct fd_hook_hdl * hookhdl = NULL; 46 47 47 48 static int ta_conf_init(void) … … 96 97 while (1) { 97 98 /* Display statistics every XX seconds */ 98 sleep(ta_conf->bench_duration *3);99 sleep(ta_conf->bench_duration + 3); 99 100 100 101 /* Now, get the current stats */ … … 136 137 } 137 138 139 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) { 140 141 } 142 143 138 144 /* entry point */ 139 145 static int ta_entry(char * conffile) … … 172 178 CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) ); 173 179 180 if (ta_conf->mode & MODE_BENCH) { 181 /* Register an empty hook to disable the default handling */ 182 CHECK_FCT( fd_hook_register( (1<<HOOK_LAST) - 1, 183 ta_hook_cb, NULL, NULL, &hookhdl) ); 184 185 } 186 174 187 /* Start the statistics thread */ 175 188 CHECK_POSIX( pthread_create(&ta_stats_th, NULL, ta_stats, NULL) ); … … 185 198 if (ta_conf->mode & MODE_SERV) 186 199 ta_serv_fini(); 200 if (hookhdl) 201 fd_hook_unregister( hookhdl ); 187 202 CHECK_FCT_DO( fd_thr_term(&ta_stats_th), ); 188 203 CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), );
Note: See TracChangeset
for help on using the changeset viewer.