diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-07-06 14:28:45 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-07-06 14:28:45 +0000 |
commit | 163c395b2cfc15caf83ab2d46e79246c3909affd (patch) | |
tree | 825ec332bd9844fbb7edb24e28ce82097f094e91 /pjsip/src/test-pjsip | |
parent | 5b3433fba0a849002a4c880d0de53fbb560c9e0b (diff) |
Set the caching pool workspace size in pjsip-test to 2MB (configurable)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@589 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/test-pjsip')
-rw-r--r-- | pjsip/src/test-pjsip/test.c | 17 | ||||
-rw-r--r-- | pjsip/src/test-pjsip/test.h | 9 | ||||
-rw-r--r-- | pjsip/src/test-pjsip/uri_test.c | 10 |
3 files changed, 30 insertions, 6 deletions
diff --git a/pjsip/src/test-pjsip/test.c b/pjsip/src/test-pjsip/test.c index 3ae58daa..2b353ad9 100644 --- a/pjsip/src/test-pjsip/test.c +++ b/pjsip/src/test-pjsip/test.c @@ -243,7 +243,8 @@ int test_main(void) pj_dump_config(); - pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 ); + pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, + PJSIP_TEST_MEM_SIZE ); rc = pjsip_endpt_create(&caching_pool.factory, "endpt", &endpt); if (rc != PJ_SUCCESS) { @@ -340,6 +341,20 @@ int test_main(void) on_return: flush_events(500); + + /* Dumping memory pool usage */ + { + pj_pool_t *p; + unsigned sz = 0; + p = caching_pool.used_list.next; + while (p != (pj_pool_t*)&caching_pool.used_list) { + sz += pj_pool_get_capacity(p); + p = p->next; + } + PJ_LOG(3,(THIS_FILE, "Caching pool total capacity=%u", + caching_pool.capacity + sz)); + } + pjsip_endpt_destroy(endpt); pj_caching_pool_destroy(&caching_pool); diff --git a/pjsip/src/test-pjsip/test.h b/pjsip/src/test-pjsip/test.h index 969b341a..b7b79c7d 100644 --- a/pjsip/src/test-pjsip/test.h +++ b/pjsip/src/test-pjsip/test.h @@ -26,6 +26,15 @@ extern pjsip_endpoint *endpt; #define TEST_UDP_PORT 15060 #define TEST_UDP_PORT_STR "15060" +/** + * Memory size to use in caching pool. + * Default: 2MB + */ +#ifndef PJSIP_TEST_MEM_SIZE +# define PJSIP_TEST_MEM_SIZE (2*1024*1024) +#endif + + #define INCLUDE_MESSAGING_GROUP 1 #define INCLUDE_TRANSPORT_GROUP 1 diff --git a/pjsip/src/test-pjsip/uri_test.c b/pjsip/src/test-pjsip/uri_test.c index d2e55f20..06e7e27d 100644 --- a/pjsip/src/test-pjsip/uri_test.c +++ b/pjsip/src/test-pjsip/uri_test.c @@ -810,16 +810,16 @@ static int simple_uri_test(void) pj_status_t status; PJ_LOG(3,(THIS_FILE, " simple test")); - pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE); for (i=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) { + pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE); status = do_uri_test(pool, &uri_test_array[i]); + pjsip_endpt_release_pool(endpt, pool); if (status != PJ_SUCCESS) { PJ_LOG(3,(THIS_FILE, " error %d when testing entry %d", status, i)); return status; } } - pjsip_endpt_release_pool(endpt, pool); return 0; } @@ -827,7 +827,6 @@ static int simple_uri_test(void) static int uri_benchmark(unsigned *p_parse, unsigned *p_print, unsigned *p_cmp) { unsigned i, loop; - pj_pool_t *pool; pj_status_t status; pj_timestamp zero; pj_time_val elapsed; @@ -842,9 +841,11 @@ static int uri_benchmark(unsigned *p_parse, unsigned *p_print, unsigned *p_cmp) var.print_time.u32.hi = var.print_time.u32.lo = 0; var.cmp_time.u32.hi = var.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) { + pj_pool_t *pool; + pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE); status = do_uri_test(pool, &uri_test_array[i]); + pjsip_endpt_release_pool(endpt, pool); if (status != PJ_SUCCESS) { PJ_LOG(3,(THIS_FILE, " error %d when testing entry %d", status, i)); @@ -852,7 +853,6 @@ static int uri_benchmark(unsigned *p_parse, unsigned *p_print, unsigned *p_cmp) goto on_return; } } - pjsip_endpt_release_pool(endpt, pool); } kbytes = var.parse_len; |