Navigation



Ignore:
Timestamp:
Jun 12, 2019, 9:54:35 PM (5 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

test_cc, loadtest_cc: write current statistics every second

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/loadtest_cc/loadtest_cc.c

    r1371 r1372  
    6868} statistics;
    6969
     70void print_statistics(void) {
     71        uint64_t missing;
     72
     73        if (statistics.first == 0 || statistics.last == 0 || statistics.last == statistics.first) {
     74                return;
     75        }
     76
     77        missing = statistics.sent - statistics.error - statistics.success;
     78
     79        fd_log_error("%s: %lld CCR messages sent in %llds (%.2f messages/second), %lld success (%.2f%%), %lld errors (%.2f%%), %lld missing (%.2f%%)",
     80                     fd_g_config->cnf_diamid,
     81                     (long long)statistics.sent, (long long)(statistics.last-statistics.first), (float)statistics.sent / (statistics.last-statistics.first),
     82                     (long long)statistics.success,
     83                     100*(float)statistics.success/statistics.sent, (long long)statistics.error, 100*(float)statistics.error/statistics.sent,
     84                     missing, 100*(float)missing/statistics.sent);
     85}
     86
    7087static int handle_message(struct msg **msg) {
    7188        struct msg_hdr *hdr = NULL;
     
    299316        do {
    300317                if (do_generate) {
     318                        time_t now;
    301319                        if (statistics.first == 0) {
    302320                                statistics.first = time(NULL);
     
    305323                        fd_msg_send(&msg, NULL, NULL);
    306324                        fd_log_debug("[%s] sent message", MODULE_NAME);
     325                        now = time(NULL);
     326                        if (statistics.last != now) {
     327                                print_statistics();
     328                        }
    307329                        statistics.last = time(NULL);
    308330                        statistics.sent++;
     
    387409void fd_ext_fini(void)
    388410{
    389         uint64_t missing;
    390411        /* stop sending */
    391412        do_generate = 0;
     
    400421        }
    401422
    402         missing = statistics.sent - statistics.error - statistics.success;
    403 
    404         fd_log_error("%lld messages sent in %llds (%.2f messages/second), %lld success (%.2f%%), %lld errors (%.2f%%), %lld missing (%.2f%%)",
    405                      (long long)statistics.sent, (long long)(statistics.last-statistics.first), (float)statistics.sent / (statistics.last-statistics.first),
    406                      (long long)statistics.success,
    407                      100*(float)statistics.success/statistics.sent, (long long)statistics.error, 100*(float)statistics.error/statistics.sent,
    408                      missing, 100*(float)missing/statistics.sent);
     423        print_statistics();
    409424
    410425        return;
Note: See TracChangeset for help on using the changeset viewer.