Changeset 601 for pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
- Timestamp:
- Jul 10, 2006 9:39:24 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
r595 r601 73 73 #define THIS_FILE "pjsip-perf.c" 74 74 #define DEFAULT_COUNT (PJSIP_MAX_TSX_COUNT/2>10000?10000:PJSIP_MAX_TSX_COUNT/2) 75 #define JOB_WINDOW DEFAULT_COUNT75 #define JOB_WINDOW 1000 76 76 #define TERMINATE_TSX(x,c) 77 77 … … 138 138 pj_bool_t real_sdp; 139 139 pjmedia_sdp_session *dummy_sdp; 140 pj_bool_t verbose; 140 141 int log_level; 141 142 142 143 struct { … … 151 152 unsigned stat_max_window; 152 153 pj_time_val first_request; 154 pj_time_val requests_sent; 153 155 pj_time_val last_completion; 154 156 unsigned total_responses; … … 469 471 static pj_bool_t logger_on_rx_msg(pjsip_rx_data *rdata) 470 472 { 471 PJ_LOG( 4,(THIS_FILE, "RX %d bytes %s from%s:%d:\n"473 PJ_LOG(3,(THIS_FILE, "RX %d bytes %s from %s %s:%d:\n" 472 474 "%.*s\n" 473 475 "--end msg--", 474 476 rdata->msg_info.len, 475 477 pjsip_rx_data_get_info(rdata), 478 rdata->tp_info.transport->type_name, 476 479 rdata->pkt_info.src_name, 477 480 rdata->pkt_info.src_port, … … 493 496 */ 494 497 495 PJ_LOG( 4,(THIS_FILE, "TX %d bytes %s to%s:%d:\n"498 PJ_LOG(3,(THIS_FILE, "TX %d bytes %s to %s %s:%d:\n" 496 499 "%.*s\n" 497 500 "--end msg--", 498 501 (tdata->buf.cur - tdata->buf.start), 499 502 pjsip_tx_data_get_info(tdata), 503 tdata->tp_info.transport->type_name, 500 504 tdata->tp_info.dst_name, 501 505 tdata->tp_info.dst_port, … … 979 983 "\n" 980 984 "where:\n" 981 " URL The URL to be contacted\n"985 " URL The SIP URL to be contacted.\n" 982 986 "\n" 983 "and OPTIONS are:\n" 984 " --count=N, -n Set number of requests to initiate\n" 985 " (client only, default=%d)\n" 986 " --method=METHOD, -m Set the test method (default: OPTIONS)\n" 987 "Client options:\n" 988 " --method=METHOD, -m Set the test method [default: OPTIONS]\n" 989 " --count=N, -n Set total number of requests to initiate\n" 990 " [default=%d]\n" 991 " --stateless, -s Set to operate in stateless mode\n" 992 " [default: stateful]\n" 993 " --timeout=SEC, -t Set client timeout [default=60 sec]\n" 994 " --window=COUNT, -w Set maximum outstanding job [default: %d]\n" 995 "\n" 996 "SDP options (client and server):\n" 997 " --real-sdp Generate real SDP from pjmedia, and also perform\n" 998 " proper SDP negotiation [default: dummy]\n" 999 "\n" 1000 "Client and Server options:\n" 987 1001 " --local-port=PORT, -p Set local port [default: 5060]\n" 988 " --use-tcp, -T Use TCP instead of UDP (default: no)\n" 989 " --thread-count=N Set number of worker threads (default=1)\n" 990 " --stateless, -s Set client to operate in stateless mode\n" 991 " (default: stateful)\n" 992 " --window=COUNT, -w Set maximum outstanding job in client (default: %d)\n" 993 " --real-sdp Generate real SDP from pjmedia, and also perform\n" 994 " proper SDP negotiation (default: dummy)\n" 995 " --timeout=SEC, -t Set client timeout (default=60 sec)\n" 1002 " --use-tcp, -T Use TCP instead of UDP [default: no]\n" 1003 " --thread-count=N Set number of worker threads [default=1]\n" 1004 "\n" 1005 "Misc options:\n" 996 1006 " --help, -h Display this screen\n" 997 " --verbose, -v Display verbose logging \n"1007 " --verbose, -v Display verbose logging (can be put more than once)\n" 998 1008 "\n" 999 1009 "When started as server, pjsip-perf can be contacted on the following URIs:\n" 1000 " - sip:0@server-addr To handle requests statelessly (non-INVITE only)\n"1001 " - sip:1@server-addr To handle requests statefully (INVITE and non-INVITE)\n"1002 " - sip:2@server-addr To handle INVITE call (INVITE only)\n",1010 " - sip:0@server-addr To handle requests statelessly.\n" 1011 " - sip:1@server-addr To handle requests statefully.\n" 1012 " - sip:2@server-addr To handle INVITE call.\n", 1003 1013 DEFAULT_COUNT, JOB_WINDOW); 1004 1014 } … … 1039 1049 app.client.job_window = c = JOB_WINDOW; 1040 1050 app.client.timeout = 60; 1051 app.log_level = 3; 1041 1052 1042 1053 … … 1096 1107 1097 1108 case 'v': 1098 app. verbose = PJ_TRUE;1109 app.log_level++; 1099 1110 break; 1100 1111 … … 1260 1271 /* Submit all jobs */ 1261 1272 while (app.client.job_submitted < app.client.job_count && !app.thread_quit) { 1262 pj_time_val timeout = { 0, 0};1273 pj_time_val timeout = { 0, 1 }; 1263 1274 unsigned i; 1264 1275 int outstanding; … … 1304 1315 } 1305 1316 1317 if (app.client.requests_sent.sec == 0) { 1318 pj_gettimeofday(&app.client.requests_sent); 1319 } 1320 1321 1306 1322 /* Wait until all jobs completes, or timed out */ 1307 do { 1308 pj_time_val timeout = { 0, 0 }; 1323 pj_gettimeofday(&now); 1324 while (now.sec < end_time.sec && 1325 app.client.job_finished < app.client.job_count && 1326 !app.thread_quit) 1327 { 1328 pj_time_val timeout = { 0, 1 }; 1309 1329 unsigned i; 1310 1330 1311 for (i=0; i< 2000; ++i) {1331 for (i=0; i<1000; ++i) { 1312 1332 pjsip_endpt_handle_events2(app.sip_endpt, &timeout, NULL); 1313 1333 } 1314 1334 1315 1335 pj_gettimeofday(&now); 1316 1317 } while (now.sec < end_time.sec && 1318 app.client.job_finished < app.client.job_count && 1319 !app.thread_quit); 1336 } 1320 1337 1321 1338 return 0; … … 1343 1360 static int server_thread(void *arg) 1344 1361 { 1345 pj_time_val timeout = { 0, 0};1362 pj_time_val timeout = { 0, 1 }; 1346 1363 unsigned thread_index = (unsigned)arg; 1347 1364 pj_time_val last_report, next_report; … … 1428 1445 return 1; 1429 1446 1430 if (app.verbose) { 1431 pj_log_set_level(4); 1447 pj_log_set_level(app.log_level); 1448 1449 if (app.log_level > 3) { 1432 1450 pjsip_endpt_register_module(app.sip_endpt, &msg_logger); 1433 } else {1434 pj_log_set_level(3);1435 1451 } 1436 1452 … … 1438 1454 /* Misc infos */ 1439 1455 if (app.client.dst_uri.slen != 0) { 1440 if (app.client.method.id == PJSIP_INVITE_METHOD && 1441 app.client.stateless) 1442 { 1443 PJ_LOG(3,(THIS_FILE, 1444 "Info: --stateless option makes no sense for INVITE, " 1445 "ignored.")); 1446 } 1447 } 1448 1449 if (app.real_sdp) { 1450 PJ_LOG(3,(THIS_FILE, 1451 "Info: client/server using real SDP from PJMEDIA")); 1452 } else { 1453 PJ_LOG(3,(THIS_FILE, "Info: client/server using dummy SDP")); 1454 } 1456 if (app.client.method.id == PJSIP_INVITE_METHOD) { 1457 if (app.client.stateless) { 1458 PJ_LOG(3,(THIS_FILE, 1459 "Info: --stateless option makes no sense for INVITE," 1460 " ignored.")); 1461 } 1462 } 1463 1464 } 1465 1455 1466 1456 1467 … … 1459 1470 pj_status_t status; 1460 1471 char test_type[64]; 1461 unsigned msec ;1472 unsigned msec_req, msec_res; 1462 1473 unsigned i; 1463 1474 … … 1476 1487 1477 1488 1478 PJ_LOG(3,(THIS_FILE, "Sending %d %s to %.*s, please wait..",1489 PJ_LOG(3,(THIS_FILE, "Sending %d %s to '%.*s' with %d maximum outstanding jobs, please wait..", 1479 1490 app.client.job_count, test_type, 1480 (int)app.client.dst_uri.slen, app.client.dst_uri.ptr)); 1491 (int)app.client.dst_uri.slen, app.client.dst_uri.ptr, 1492 app.client.job_window)); 1481 1493 1482 1494 for (i=0; i<app.thread_count; ++i) { … … 1498 1510 duration = app.client.last_completion; 1499 1511 PJ_TIME_VAL_SUB(duration, app.client.first_request); 1500 msec = PJ_TIME_VAL_MSEC(duration);1512 msec_res = PJ_TIME_VAL_MSEC(duration); 1501 1513 } else { 1502 msec = app.client.timeout * 1000; 1503 } 1504 1505 if (msec == 0) msec = 1; 1514 msec_res = app.client.timeout * 1000; 1515 } 1516 1517 if (msec_res == 0) msec_res = 1; 1518 1519 if (app.client.requests_sent.sec) { 1520 pj_time_val duration; 1521 duration = app.client.requests_sent; 1522 PJ_TIME_VAL_SUB(duration, app.client.first_request); 1523 msec_req = PJ_TIME_VAL_MSEC(duration); 1524 } else { 1525 msec_req = app.client.timeout * 1000; 1526 } 1527 1528 if (msec_req == 0) msec_req = 1; 1529 1506 1530 1507 1531 pj_ansi_snprintf( 1508 1532 report, sizeof(report), 1509 "Total %d %s sent, %d responses received in %d ms:\n" 1533 "Total %d %s sent in %d ms at rate %d/sec\n" 1534 "Total %d responses receieved in %d ms:\n" 1510 1535 " - 2xx responses: %7d (rate=%d/sec)\n" 1511 1536 " - 3xx responses: %7d (rate=%d/sec)\n" … … 1516 1541 " ----------------\n" 1517 1542 " TOTAL responses: %7d (rate=%d/sec)\n", 1518 app.client.job_submitted, test_type, 1519 app.client.total_responses, msec, 1520 app.client.status_class[2], app.client.status_class[2]*1000/msec, 1521 app.client.status_class[3], app.client.status_class[3]*1000/msec, 1522 app.client.status_class[4], app.client.status_class[4]*1000/msec, 1523 app.client.status_class[5], app.client.status_class[5]*1000/msec, 1524 app.client.status_class[6], app.client.status_class[6]*1000/msec, 1525 app.client.status_class[7], app.client.status_class[7]*1000/msec, 1526 app.client.total_responses, app.client.total_responses*1000/msec); 1543 app.client.job_submitted, test_type, msec_req, 1544 app.client.job_submitted * 1000 / msec_req, 1545 app.client.total_responses, msec_res, 1546 app.client.status_class[2], app.client.status_class[2]*1000/msec_res, 1547 app.client.status_class[3], app.client.status_class[3]*1000/msec_res, 1548 app.client.status_class[4], app.client.status_class[4]*1000/msec_res, 1549 app.client.status_class[5], app.client.status_class[5]*1000/msec_res, 1550 app.client.status_class[6], app.client.status_class[6]*1000/msec_res, 1551 app.client.status_class[7], app.client.status_class[7]*1000/msec_res, 1552 app.client.total_responses, app.client.total_responses*1000/msec_res); 1527 1553 1528 1554 write_report(report);
Note: See TracChangeset
for help on using the changeset viewer.