Changeset 602 for pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
- Timestamp:
- Jul 11, 2006 9:53:27 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
r601 r602 986 986 "\n" 987 987 "Client options:\n" 988 " --method=METHOD, -m Set the test method [default: OPTIONS]\n" 988 " --method=METHOD, -m Set test method (set to INVITE for call benchmark)\n" 989 " [default: OPTIONS]\n" 989 990 " --count=N, -n Set total number of requests to initiate\n" 990 991 " [default=%d]\n" … … 1000 1001 "Client and Server options:\n" 1001 1002 " --local-port=PORT, -p Set local port [default: 5060]\n" 1002 " --use-tcp, -T Use TCP instead of UDP [default: no]\n" 1003 " --use-tcp, -T Use TCP instead of UDP. Note that when started as\n" 1004 " client, you must add ;transport=tcp parameter to URL\n" 1005 " [default: no]\n" 1003 1006 " --thread-count=N Set number of worker threads [default=1]\n" 1004 1007 "\n" 1005 1008 "Misc options:\n" 1006 1009 " --help, -h Display this screen\n" 1007 " --verbose, -v Display verbose logging (can be put more than once)\n"1010 " --verbose, -v Verbose logging (put more than once for even more)\n" 1008 1011 "\n" 1009 1012 "When started as server, pjsip-perf can be contacted on the following URIs:\n" … … 1256 1259 { 1257 1260 unsigned last_timeout_check = 0; 1258 pj_time_val end_time, now; 1259 1260 PJ_UNUSED_ARG(arg); 1261 pj_time_val end_time, last_report, now; 1262 unsigned thread_index = (unsigned)arg; 1261 1263 1262 1264 pj_thread_sleep(100); … … 1265 1267 end_time.sec += app.client.timeout; 1266 1268 1269 pj_gettimeofday(&last_report); 1270 1267 1271 if (app.client.first_request.sec == 0) { 1268 1272 pj_gettimeofday(&app.client.first_request); … … 1270 1274 1271 1275 /* Submit all jobs */ 1272 while (app.client.job_submitted < app.client.job_count && !app.thread_quit) 1276 while (app.client.job_submitted < app.client.job_count && !app.thread_quit){ 1273 1277 pj_time_val timeout = { 0, 1 }; 1274 1278 unsigned i; … … 1306 1310 pjsip_endpt_handle_events2(app.sip_endpt, &timeout, NULL); 1307 1311 1308 /* Check for time out */1309 if (app.client.job_submitted - last_timeout_check >= 2000) {1312 /* Check for time out, also print report */ 1313 if (app.client.job_submitted - last_timeout_check >= 500) { 1310 1314 pj_gettimeofday(&now); 1311 if (PJ_TIME_VAL_GTE(now, end_time)) 1315 if (PJ_TIME_VAL_GTE(now, end_time)) { 1312 1316 break; 1317 } 1313 1318 last_timeout_check = app.client.job_submitted; 1319 1320 1321 if (thread_index == 0 && now.sec-last_report.sec >= 2) { 1322 printf("\r%d jobs started, %d completed... ", 1323 app.client.job_submitted, app.client.job_finished); 1324 fflush(stdout); 1325 last_report = now; 1326 } 1314 1327 } 1315 1328 } … … 1320 1333 1321 1334 1335 if (thread_index == 0) { 1336 printf("\r%d jobs started, %d completed%s\n", 1337 app.client.job_submitted, app.client.job_finished, 1338 (app.client.job_submitted!=app.client.job_finished ? 1339 ", waiting..." : ".") ); 1340 fflush(stdout); 1341 } 1342 1322 1343 /* Wait until all jobs completes, or timed out */ 1323 1344 pj_gettimeofday(&now); 1324 while ( now.sec < end_time.sec&&1345 while (PJ_TIME_VAL_LT(now, end_time) && 1325 1346 app.client.job_finished < app.client.job_count && 1326 1347 !app.thread_quit) … … 1330 1351 1331 1352 for (i=0; i<1000; ++i) { 1332 pjsip_endpt_handle_events2(app.sip_endpt, &timeout, NULL); 1353 unsigned count; 1354 count = 0; 1355 pjsip_endpt_handle_events2(app.sip_endpt, &timeout, &count); 1356 if (count == 0) 1357 break; 1358 } 1359 1360 pj_gettimeofday(&now); 1361 } 1362 1363 /* Wait couple of seconds if there are still unfinished jobs */ 1364 pj_gettimeofday(&now); 1365 end_time = now; 1366 end_time.sec += 2; 1367 while (PJ_TIME_VAL_LT(now, end_time) && 1368 app.client.job_finished < app.client.job_submitted) 1369 { 1370 pj_time_val timeout = { 0, 1 }; 1371 unsigned i; 1372 1373 for (i=0; i<1000; ++i) { 1374 unsigned count; 1375 count = 0; 1376 pjsip_endpt_handle_events2(app.sip_endpt, &timeout, &count); 1377 if (count == 0) 1378 break; 1333 1379 } 1334 1380 … … 1432 1478 { 1433 1479 static char report[1024]; 1480 1481 puts("PJSIP Performance Measurement Tool\n" 1482 "(c)2006 pjsip.org\n"); 1434 1483 1435 1484 if (create_app() != 0) … … 1487 1536 1488 1537 1489 PJ_LOG(3,(THIS_FILE, "Sending %d %s to '%.*s' with %d maximum outstanding jobs, please wait..",1538 printf("Sending %d %s to '%.*s' with %d maximum outstanding jobs, please wait..\n", 1490 1539 app.client.job_count, test_type, 1491 1540 (int)app.client.dst_uri.slen, app.client.dst_uri.ptr, 1492 app.client.job_window) );1541 app.client.job_window); 1493 1542 1494 1543 for (i=0; i<app.thread_count; ++i) { 1495 status = pj_thread_create(app.pool, NULL, &client_thread, NULL,1544 status = pj_thread_create(app.pool, NULL, &client_thread, (void*)i, 1496 1545 0, 0, &app.thread[i]); 1497 1546 if (status != PJ_SUCCESS) { … … 1528 1577 if (msec_req == 0) msec_req = 1; 1529 1578 1579 if (app.client.job_submitted < app.client.job_count) 1580 puts("\ntimed-out!\n"); 1581 else 1582 puts("\ndone.\n"); 1530 1583 1531 1584 pj_ansi_snprintf( 1532 1585 report, sizeof(report), 1533 "Total %d %s sent in %d ms at rate %d/sec\n"1586 "Total %d %s sent in %d ms at rate of %d/sec\n" 1534 1587 "Total %d responses receieved in %d ms:\n" 1535 1588 " - 2xx responses: %7d (rate=%d/sec)\n"
Note: See TracChangeset
for help on using the changeset viewer.