Changeset 1372:6b1a2405cebb in freeDiameter
- Timestamp:
- Jun 12, 2019, 9:54:35 PM (5 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/loadtest_cc/loadtest_cc.c
r1371 r1372 68 68 } statistics; 69 69 70 void 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 70 87 static int handle_message(struct msg **msg) { 71 88 struct msg_hdr *hdr = NULL; … … 299 316 do { 300 317 if (do_generate) { 318 time_t now; 301 319 if (statistics.first == 0) { 302 320 statistics.first = time(NULL); … … 305 323 fd_msg_send(&msg, NULL, NULL); 306 324 fd_log_debug("[%s] sent message", MODULE_NAME); 325 now = time(NULL); 326 if (statistics.last != now) { 327 print_statistics(); 328 } 307 329 statistics.last = time(NULL); 308 330 statistics.sent++; … … 387 409 void fd_ext_fini(void) 388 410 { 389 uint64_t missing;390 411 /* stop sending */ 391 412 do_generate = 0; … … 400 421 } 401 422 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(); 409 424 410 425 return; -
extensions/test_cc/test_cc.c
r1365 r1372 42 42 #define MODULE_NAME "test_cc" 43 43 44 struct statistics { 45 uint64_t sent; 46 time_t first; 47 time_t last; 48 } statistics; 49 50 void print_statistics(void) { 51 if (statistics.first == 0 || statistics.last == 0 || statistics.last == statistics.first) { 52 return; 53 } 54 55 fd_log_error("%s: %lld CCA messages sent in %llds (%.2f messages/second)", fd_g_config->cnf_diamid, 56 (long long)statistics.sent, (long long)(statistics.last-statistics.first), (float)statistics.sent / (statistics.last-statistics.first)); 57 } 58 44 59 static int ccr_handler(struct msg ** msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act) 45 60 { 46 61 struct msg_hdr *hdr = NULL; 62 time_t now; 47 63 48 64 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); … … 134 150 /* Send the answer */ 135 151 CHECK_FCT(fd_msg_send(msg, NULL, NULL)); 152 now = time(NULL); 153 if (!statistics.first) { 154 statistics.first = now; 155 } 156 if (statistics.last != now) { 157 print_statistics(); 158 } 159 statistics.last = now; 160 statistics.sent++; 136 161 fd_log_debug("reply sent"); 137 162 } else { … … 171 196 } 172 197 198 /* And terminate it */ 199 void fd_ext_fini(void) 200 { 201 /* Unregister the callbacks */ 202 if (ccr_handler_hdl) { 203 CHECK_FCT_DO( fd_disp_unregister(&ccr_handler_hdl, NULL), ); 204 ccr_handler_hdl = NULL; 205 } 206 207 print_statistics(); 208 209 return; 210 } 211 212 173 213 EXTENSION_ENTRY(MODULE_NAME, cc_entry);
Note: See TracChangeset
for help on using the changeset viewer.