Navigation


Changeset 1195:16f2d2f15e5b in freeDiameter for extensions


Ignore:
Timestamp:
Jun 11, 2013, 3:05:33 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Allow better usage in benchmark mode

Location:
extensions/test_app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/test_app/ta_bench.c

    r974 r1195  
    206206       
    207207        /* We will run for ta_conf->bench_duration seconds */
     208        LOG_N("Starting benchmark client, %ds", ta_conf->bench_duration);
    208209        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &end_time), );
    209210        end_time.tv_sec += ta_conf->bench_duration;
     
    236237       
    237238        /* Now, display the statistics */
    238         fd_log_debug( "------- app_test Benchmark result ---------");
     239        LOG_N( "------- app_test Benchmark result ---------");
    239240        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",
    241242                                (int)(now.tv_sec + ta_conf->bench_duration - end_time.tv_sec),
    242243                                (long)(now.tv_nsec - end_time.tv_nsec) / 1000);
    243244        } else {
    244                 fd_log_debug( " Executing for: %d.%06ld sec",
     245                LOG_N( " Executing for: %d.%06ld sec",
    245246                                (int)(now.tv_sec + ta_conf->bench_duration - 1 - end_time.tv_sec),
    246247                                (long)(now.tv_nsec + 1000000000 - end_time.tv_nsec) / 1000);
    247248        }
    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( "-------------------------------------");
    257258
    258259}
  • extensions/test_app/test_app.c

    r1127 r1195  
    4444static struct ta_conf _conf;
    4545static pthread_t ta_stats_th = (pthread_t)NULL;
     46static struct fd_hook_hdl * hookhdl = NULL;
    4647
    4748static int ta_conf_init(void)
     
    9697        while (1) {
    9798                /* Display statistics every XX seconds */
    98                 sleep(ta_conf->bench_duration * 3);
     99                sleep(ta_conf->bench_duration + 3);
    99100               
    100101                /* Now, get the current stats */
     
    136137}
    137138
     139static 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
    138144/* entry point */
    139145static int ta_entry(char * conffile)
     
    172178        CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) );
    173179       
     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       
    174187        /* Start the statistics thread */
    175188        CHECK_POSIX( pthread_create(&ta_stats_th, NULL, ta_stats, NULL) );
     
    185198        if (ta_conf->mode & MODE_SERV)
    186199                ta_serv_fini();
     200        if (hookhdl)
     201                fd_hook_unregister( hookhdl );
    187202        CHECK_FCT_DO( fd_thr_term(&ta_stats_th), );
    188203        CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), );
Note: See TracChangeset for help on using the changeset viewer.