Ignore:
Timestamp:
Jul 11, 2006 9:53:27 AM (18 years ago)
Author:
bennylp
Message:

Added PJSIP_MAX_NET_EVENTS configuration to pjsip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c

    r601 r602  
    986986        "\n" 
    987987        "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" 
    989990        "   --count=N, -n           Set total number of requests to initiate\n" 
    990991        "                           [default=%d]\n" 
     
    10001001        "Client and Server options:\n" 
    10011002        "   --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" 
    10031006        "   --thread-count=N        Set number of worker threads [default=1]\n" 
    10041007        "\n" 
    10051008        "Misc options:\n" 
    10061009        "   --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" 
    10081011        "\n" 
    10091012        "When started as server, pjsip-perf can be contacted on the following URIs:\n" 
     
    12561259{ 
    12571260    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; 
    12611263 
    12621264    pj_thread_sleep(100); 
     
    12651267    end_time.sec += app.client.timeout; 
    12661268 
     1269    pj_gettimeofday(&last_report); 
     1270 
    12671271    if (app.client.first_request.sec == 0) { 
    12681272        pj_gettimeofday(&app.client.first_request); 
     
    12701274 
    12711275    /* 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){ 
    12731277        pj_time_val timeout = { 0, 1 }; 
    12741278        unsigned i; 
     
    13061310        pjsip_endpt_handle_events2(app.sip_endpt, &timeout, NULL); 
    13071311 
    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) { 
    13101314            pj_gettimeofday(&now); 
    1311             if (PJ_TIME_VAL_GTE(now, end_time)) 
     1315            if (PJ_TIME_VAL_GTE(now, end_time)) { 
    13121316                break; 
     1317            } 
    13131318            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            } 
    13141327        } 
    13151328    } 
     
    13201333 
    13211334 
     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 
    13221343    /* Wait until all jobs completes, or timed out */ 
    13231344    pj_gettimeofday(&now); 
    1324     while (now.sec < end_time.sec &&  
     1345    while (PJ_TIME_VAL_LT(now, end_time) &&  
    13251346           app.client.job_finished < app.client.job_count &&  
    13261347           !app.thread_quit)  
     
    13301351 
    13311352        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; 
    13331379        } 
    13341380 
     
    14321478{ 
    14331479    static char report[1024]; 
     1480 
     1481    puts("PJSIP Performance Measurement Tool\n" 
     1482        "(c)2006 pjsip.org\n"); 
    14341483 
    14351484    if (create_app() != 0) 
     
    14871536         
    14881537 
    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",  
    14901539                  app.client.job_count, test_type, 
    14911540                  (int)app.client.dst_uri.slen, app.client.dst_uri.ptr, 
    1492                   app.client.job_window)); 
     1541                  app.client.job_window); 
    14931542 
    14941543        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, 
    14961545                                      0, 0, &app.thread[i]); 
    14971546            if (status != PJ_SUCCESS) { 
     
    15281577        if (msec_req == 0) msec_req = 1; 
    15291578 
     1579        if (app.client.job_submitted < app.client.job_count) 
     1580            puts("\ntimed-out!\n"); 
     1581        else 
     1582            puts("\ndone.\n"); 
    15301583 
    15311584        pj_ansi_snprintf( 
    15321585            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" 
    15341587            "Total %d responses receieved in %d ms:\n" 
    15351588            " - 2xx responses:  %7d (rate=%d/sec)\n" 
Note: See TracChangeset for help on using the changeset viewer.