Optimization here and there, changes because of PJLIB modifications
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@74 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
de5f4643c3
commit
5b91744a73
|
@ -42,7 +42,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /Zi /O2 /Ob2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
|
|
|
@ -67,7 +67,7 @@ enum
|
|||
typedef struct pjsip_parser_err_report
|
||||
{
|
||||
PJ_DECL_LIST_MEMBER(struct pjsip_parser_err_report);
|
||||
int exception_code; /**< Error exception (e.g. PJSIP_SYN_ERR_EXCEPTION) */
|
||||
int except_code; /**< Error exception (e.g. PJSIP_SYN_ERR_EXCEPTION) */
|
||||
int line; /**< Line number. */
|
||||
int col; /**< Column number. */
|
||||
pj_str_t hname; /**< Header name, if any. */
|
||||
|
|
|
@ -336,7 +336,7 @@ PJ_DEF(pjsip_event_sub*) pjsip_event_sub_create( pjsip_endpoint *endpt,
|
|||
pj_mutex_unlock( mgr.mutex );
|
||||
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
PJ_LOG(4,(THIS_FILE, "event_sub%p (%s): caught exception %d during init",
|
||||
sub, state[sub->state].ptr, PJ_GET_EXCEPTION()));
|
||||
|
||||
|
|
|
@ -756,7 +756,7 @@ PJ_DEF(pjsip_tx_data*) pjsip_dlg_create_request( pjsip_dlg *dlg,
|
|||
dlg_create_request_throw(&tdata, dlg, method, cseq);
|
||||
PJ_LOG(5, (dlg->obj_name, "request data %s created", tdata->obj_name));
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
/* Failed! Delete transmit data. */
|
||||
if (tdata) {
|
||||
pjsip_tx_data_dec_ref( tdata );
|
||||
|
|
|
@ -183,7 +183,7 @@ static unsigned long pj_strtoul_mindigit(const pj_str_t *str,
|
|||
}
|
||||
|
||||
/* Case insensitive comparison */
|
||||
#define parser_stricmp(str1, str2) pj_stricmp(&str1, &str2)
|
||||
#define parser_stricmp(s1, s2) (pj_stricmp_alnum(&s1, &s2))
|
||||
|
||||
|
||||
/* Syntax error handler for parser. */
|
||||
|
@ -551,7 +551,7 @@ PJ_DEF(pjsip_msg*) pjsip_parse_msg( pj_pool_t *pool,
|
|||
PJ_TRY {
|
||||
msg = int_parse_msg(&context, err_list);
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
msg = NULL;
|
||||
}
|
||||
PJ_END
|
||||
|
@ -580,7 +580,7 @@ PJ_DEF(pjsip_msg *) pjsip_parse_rdata( char *buf, pj_size_t size,
|
|||
PJ_TRY {
|
||||
rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err);
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
rdata->msg_info.msg = NULL;
|
||||
}
|
||||
PJ_END
|
||||
|
@ -656,7 +656,10 @@ PJ_DEF(pj_bool_t) pjsip_find_msg( const char *buf, pj_size_t size,
|
|||
|
||||
/* Found a valid Content-Length header. */
|
||||
content_length = pj_strtoul(&str_clen);
|
||||
}
|
||||
}
|
||||
PJ_CATCH_ANY {
|
||||
content_length = -1;
|
||||
}
|
||||
PJ_END
|
||||
|
||||
pj_scan_fini(&scanner);
|
||||
|
@ -691,9 +694,9 @@ PJ_DEF(pjsip_uri*) pjsip_parse_uri( pj_pool_t *pool,
|
|||
char *buf, pj_size_t size,
|
||||
unsigned option)
|
||||
{
|
||||
PJ_USE_EXCEPTION;
|
||||
pj_scanner scanner;
|
||||
pjsip_uri *uri = NULL;
|
||||
PJ_USE_EXCEPTION;
|
||||
|
||||
init_sip_parser();
|
||||
|
||||
|
@ -703,6 +706,9 @@ PJ_DEF(pjsip_uri*) pjsip_parse_uri( pj_pool_t *pool,
|
|||
PJ_TRY {
|
||||
uri = int_parse_uri_or_name_addr(&scanner, pool, option);
|
||||
}
|
||||
PJ_CATCH_ANY {
|
||||
uri = NULL;
|
||||
}
|
||||
PJ_END;
|
||||
|
||||
/* Must have exhausted all inputs. */
|
||||
|
@ -738,12 +744,12 @@ static int generic_print_body (pjsip_msg_body *msg_body,
|
|||
static pjsip_msg *int_parse_msg( pjsip_parse_ctx *ctx,
|
||||
pjsip_parser_err_report *err_list)
|
||||
{
|
||||
PJ_USE_EXCEPTION;
|
||||
int ch;
|
||||
pjsip_msg *msg;
|
||||
pjsip_ctype_hdr *ctype_hdr = NULL;
|
||||
pj_scanner *scanner = ctx->scanner;
|
||||
pj_pool_t *pool = ctx->pool;
|
||||
PJ_USE_EXCEPTION;
|
||||
|
||||
/* Skip leading newlines. */
|
||||
ch = *scanner->curptr;
|
||||
|
@ -800,7 +806,7 @@ static pjsip_msg *int_parse_msg( pjsip_parse_ctx *ctx,
|
|||
}
|
||||
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
/* Exception was thrown during parsing.
|
||||
* Skip until newline, and parse next header.
|
||||
*/
|
||||
|
@ -815,7 +821,7 @@ static pjsip_msg *int_parse_msg( pjsip_parse_ctx *ctx,
|
|||
pjsip_parser_err_report *err_info;
|
||||
|
||||
err_info = pj_pool_alloc(pool, sizeof(*err_info));
|
||||
err_info->exception_code = PJ_GET_EXCEPTION();
|
||||
err_info->except_code = PJ_GET_EXCEPTION();
|
||||
err_info->line = scanner->line;
|
||||
err_info->col = scanner->col;
|
||||
err_info->hname = hname;
|
||||
|
@ -1079,10 +1085,9 @@ static pjsip_url *int_parse_sip_url( pj_scanner *scanner,
|
|||
pj_bool_t parse_params)
|
||||
{
|
||||
pj_str_t scheme;
|
||||
pjsip_url *url;
|
||||
pjsip_url *url = NULL;
|
||||
int colon;
|
||||
int skip_ws = scanner->skip_ws;
|
||||
int hsep = '?';
|
||||
scanner->skip_ws = 0;
|
||||
|
||||
pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &scheme);
|
||||
|
@ -1114,7 +1119,8 @@ static pjsip_url *int_parse_sip_url( pj_scanner *scanner,
|
|||
int_parse_uri_host_port(scanner, &url->host, &url->port);
|
||||
|
||||
/* Get URL parameters. */
|
||||
while ( parse_params && *scanner->curptr == ';' ) {
|
||||
if (parse_params) {
|
||||
while (*scanner->curptr == ';' ) {
|
||||
pj_str_t pname, pvalue;
|
||||
|
||||
int_parse_param( scanner, pool, &pname, &pvalue);
|
||||
|
@ -1143,15 +1149,17 @@ static pjsip_url *int_parse_sip_url( pj_scanner *scanner,
|
|||
p->value = pvalue;
|
||||
pj_list_insert_before(&url->other_param, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get header params. */
|
||||
while (parse_params && *scanner->curptr == hsep) {
|
||||
if (parse_params && *scanner->curptr == '?') {
|
||||
do {
|
||||
pjsip_param *param;
|
||||
param = pj_pool_alloc(pool, sizeof(pjsip_param));
|
||||
int_parse_hparam(scanner, pool, ¶m->name, ¶m->value);
|
||||
pj_list_insert_before(&url->header_param, param);
|
||||
hsep = '&';
|
||||
} while (*scanner->curptr == '&');
|
||||
}
|
||||
|
||||
scanner->skip_ws = skip_ws;
|
||||
|
@ -1774,7 +1782,7 @@ PJ_DEF(void*) pjsip_parse_hdr( pj_pool_t *pool, const pj_str_t *hname,
|
|||
}
|
||||
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
hdr = NULL;
|
||||
}
|
||||
PJ_END
|
||||
|
|
|
@ -46,7 +46,7 @@ PJ_DEF(const pjsip_param*) pjsip_param_cfind( const pjsip_param *param_list,
|
|||
{
|
||||
const pjsip_param *p = param_list->next;
|
||||
while (p != param_list) {
|
||||
if (pj_stricmp(&p->name, name)==0)
|
||||
if (pj_stricmp_alnum(&p->name, name)==0)
|
||||
return p;
|
||||
p = p->next;
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_create_request( pjsip_endpoint *endpt,
|
|||
init_request_throw( endpt, tdata, &cseq->method, target, from, to,
|
||||
contact, call_id, cseq, param_text);
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
status = PJ_ENOMEM;
|
||||
goto on_error;
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ pjsip_endpt_create_request_from_hdr( pjsip_endpoint *endpt,
|
|||
init_request_throw(endpt, tdata, &cseq->method, target, from, to,
|
||||
contact, call_id, cseq, param_text);
|
||||
}
|
||||
PJ_DEFAULT {
|
||||
PJ_CATCH_ANY {
|
||||
status = PJ_ENOMEM;
|
||||
goto on_error;
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#define PASS_CHAR ALPHANUM MARK "&=+$,"
|
||||
#define PARAM_CHAR ALPHANUM MARK "[]/:&+$"
|
||||
|
||||
#define POOL_SIZE 4000
|
||||
#define LOOP_COUNT 1000
|
||||
#define POOL_SIZE 8000
|
||||
#define LOOP_COUNT 10000
|
||||
#define AVERAGE_URL_LEN 80
|
||||
#define THREAD_COUNT 4
|
||||
|
||||
static pj_uint32_t parse_len;
|
||||
static pj_timestamp parse_time, print_time;
|
||||
static pj_highprec_t parse_len, print_len, cmp_len;
|
||||
static pj_timestamp parse_time, print_time, cmp_time;
|
||||
|
||||
|
||||
/* URI creator functions. */
|
||||
|
@ -83,8 +83,7 @@ struct uri_test
|
|||
{
|
||||
PJ_SUCCESS,
|
||||
"sip:user:password@localhost:5060",
|
||||
&create_uri2,
|
||||
},
|
||||
&create_uri2, },
|
||||
{
|
||||
/* Port is specified should not match unspecified port. */
|
||||
ERR_NOT_EQUAL,
|
||||
|
@ -498,7 +497,7 @@ static pj_status_t do_uri_test(pj_pool_t *pool, struct uri_test *entry)
|
|||
|
||||
/* Parse URI text. */
|
||||
pj_get_timestamp(&t1);
|
||||
parse_len += entry->len;
|
||||
parse_len = parse_len + entry->len;
|
||||
parsed_uri = pjsip_parse_uri(pool, entry->str, entry->len, 0);
|
||||
if (!parsed_uri) {
|
||||
/* Parsing failed. If the entry says that this is expected, then
|
||||
|
@ -532,6 +531,7 @@ static pj_status_t do_uri_test(pj_pool_t *pool, struct uri_test *entry)
|
|||
s1.ptr[len] = '\0';
|
||||
s1.slen = len;
|
||||
|
||||
print_len = print_len + len;
|
||||
pj_get_timestamp(&t2);
|
||||
pj_sub_timestamp(&t2, &t1);
|
||||
pj_add_timestamp(&print_time, &t2);
|
||||
|
@ -545,6 +545,7 @@ static pj_status_t do_uri_test(pj_pool_t *pool, struct uri_test *entry)
|
|||
s2.slen = len;
|
||||
|
||||
/* Full comparison of parsed URI with reference URI. */
|
||||
pj_get_timestamp(&t1);
|
||||
status = pjsip_uri_cmp(PJSIP_URI_IN_OTHER, parsed_uri, ref_uri);
|
||||
if (status != 0) {
|
||||
/* Not equal. See if this is the expected status. */
|
||||
|
@ -565,6 +566,11 @@ static pj_status_t do_uri_test(pj_pool_t *pool, struct uri_test *entry)
|
|||
}
|
||||
}
|
||||
|
||||
cmp_len = cmp_len + len;
|
||||
pj_get_timestamp(&t2);
|
||||
pj_sub_timestamp(&t2, &t1);
|
||||
pj_add_timestamp(&cmp_time, &t2);
|
||||
|
||||
/* Compare text. */
|
||||
if (pj_strcmp(&s1, &s2) != 0) {
|
||||
/* Not equal. */
|
||||
|
@ -581,7 +587,8 @@ pj_status_t uri_test()
|
|||
pj_pool_t *pool;
|
||||
pj_status_t status;
|
||||
pj_timestamp zero;
|
||||
pj_highprec_t avg_parse, avg_print;
|
||||
pj_time_val elapsed;
|
||||
pj_highprec_t avg_parse, avg_print, avg_cmp, kbytes;
|
||||
|
||||
zero.u32.hi = zero.u32.lo = 0;
|
||||
|
||||
|
@ -598,39 +605,70 @@ pj_status_t uri_test()
|
|||
pjsip_endpt_destroy_pool(endpt, pool);
|
||||
|
||||
PJ_LOG(3,("", " benchmarking..."));
|
||||
parse_len = 0;
|
||||
parse_len = print_len = cmp_len = 0;
|
||||
parse_time.u32.hi = parse_time.u32.lo = 0;
|
||||
print_time.u32.hi = print_time.u32.lo = 0;
|
||||
pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE);
|
||||
cmp_time.u32.hi = cmp_time.u32.lo = 0;
|
||||
for (loop=0; loop<LOOP_COUNT; ++loop) {
|
||||
pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE);
|
||||
for (i=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
|
||||
status = do_uri_test(pool, &uri_test_array[i]);
|
||||
if (status != PJ_SUCCESS) {
|
||||
PJ_LOG(3,("uri_test", " error %d when testing entry %d",
|
||||
status, i));
|
||||
pjsip_endpt_destroy_pool(endpt, pool);
|
||||
goto on_return;
|
||||
}
|
||||
}
|
||||
pjsip_endpt_destroy_pool(endpt, pool);
|
||||
}
|
||||
|
||||
kbytes = parse_len;
|
||||
pj_highprec_mod(kbytes, 1000000);
|
||||
pj_highprec_div(kbytes, 100000);
|
||||
elapsed = pj_elapsed_time(&zero, &parse_time);
|
||||
avg_parse = pj_elapsed_usec(&zero, &parse_time);
|
||||
pj_highprec_mul(avg_parse, AVERAGE_URL_LEN);
|
||||
pj_highprec_div(avg_parse, parse_len);
|
||||
avg_parse = 1000000 / avg_parse;
|
||||
|
||||
PJ_LOG(3,("", " %u.%u MB of urls parsed in %d.%03ds (avg=%d urls/sec)",
|
||||
(unsigned)(parse_len/1000000), (unsigned)kbytes,
|
||||
elapsed.sec, elapsed.msec,
|
||||
(unsigned)avg_parse));
|
||||
|
||||
kbytes = print_len;
|
||||
pj_highprec_mod(kbytes, 1000000);
|
||||
pj_highprec_div(kbytes, 100000);
|
||||
elapsed = pj_elapsed_time(&zero, &print_time);
|
||||
avg_print = pj_elapsed_usec(&zero, &print_time);
|
||||
pj_highprec_mul(avg_print, AVERAGE_URL_LEN);
|
||||
pj_highprec_div(avg_print, parse_len);
|
||||
avg_print = 1000000 / avg_print;
|
||||
|
||||
PJ_LOG(3,("", " done. Average parse=%d url/sec, print=%d url/sec",
|
||||
(unsigned)avg_parse, (unsigned)avg_print));
|
||||
PJ_LOG(3,("", " %u.%u MB of urls printed in %d.%03ds (avg=%d urls/sec)",
|
||||
(unsigned)(print_len/1000000), (unsigned)kbytes,
|
||||
elapsed.sec, elapsed.msec,
|
||||
(unsigned)avg_print));
|
||||
|
||||
kbytes = cmp_len;
|
||||
pj_highprec_mod(kbytes, 1000000);
|
||||
pj_highprec_div(kbytes, 100000);
|
||||
elapsed = pj_elapsed_time(&zero, &cmp_time);
|
||||
avg_cmp = pj_elapsed_usec(&zero, &cmp_time);
|
||||
pj_highprec_mul(avg_cmp, AVERAGE_URL_LEN);
|
||||
pj_highprec_div(avg_cmp, cmp_len);
|
||||
avg_cmp = 1000000 / avg_cmp;
|
||||
|
||||
PJ_LOG(3,("", " %u.%u MB of urls compared in %d.%03ds (avg=%d urls/sec)",
|
||||
(unsigned)(cmp_len/1000000), (unsigned)kbytes,
|
||||
elapsed.sec, elapsed.msec,
|
||||
(unsigned)avg_cmp));
|
||||
|
||||
PJ_LOG(3,("", " multithreaded test"));
|
||||
|
||||
|
||||
on_return:
|
||||
pjsip_endpt_destroy_pool(endpt, pool);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue