Ignore:
Timestamp:
May 10, 2006 7:24:40 PM (17 years ago)
Author:
bennylp
Message:

Merge-in RTEMS port patch by Phil Torre <ptorre@…>, alpha release.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pjlib-test/pool_perf.c

    r65 r433  
    3333#define COUNT       1024 
    3434static unsigned     sizes[COUNT]; 
     35static char        *p[COUNT]; 
    3536#define MIN_SIZE    4 
    3637#define MAX_SIZE    512 
    3738static unsigned total_size; 
     39 
    3840 
    3941static int pool_test_pool() 
     
    4648    for (i=0; i<COUNT; ++i) { 
    4749        char *p; 
    48         if ( (p=(char*)pj_pool_alloc(pool, sizes[i])) == NULL) 
     50        if ( (p=(char*)pj_pool_alloc(pool, sizes[i])) == NULL) { 
     51            PJ_LOG(3,(THIS_FILE,"   error: pool failed to allocate %d bytes", 
     52                      sizes[i])); 
     53            pj_pool_release(pool); 
    4954            return -1; 
     55        } 
    5056        *p = '\0'; 
    5157    } 
     
    5763static int pool_test_malloc_free() 
    5864{ 
    59     char *p[COUNT]; 
    60     int i; 
     65    int i; /* must be signed */ 
    6166 
    6267    for (i=0; i<COUNT; ++i) { 
    6368        p[i] = (char*)malloc(sizes[i]); 
    6469        if (!p[i]) { 
    65             // Don't care for memory leak in this test 
     70            PJ_LOG(3,(THIS_FILE,"   error: malloc failed to allocate %d bytes", 
     71                      sizes[i])); 
     72            --i; 
     73            while (i >= 0) 
     74                free(p[i]), --i; 
    6675            return -1; 
    6776        } 
     
    8392    pj_uint32_t best, worst; 
    8493 
    85     // Initialize sizes. 
     94    /* Initialize size of chunks to allocate in for the test. */ 
    8695    for (i=0; i<COUNT; ++i) { 
    87         sizes[i] = MIN_SIZE + pj_rand() % MAX_SIZE; 
     96        sizes[i] = MIN_SIZE + (pj_rand() % MAX_SIZE); 
    8897        total_size += sizes[i]; 
    8998    } 
    9099 
     100    /* Add some more for pool admin area */ 
     101    total_size += 512; 
     102 
    91103    PJ_LOG(3, (THIS_FILE, "Benchmarking pool..")); 
    92104 
    93     // Warmup 
     105    /* Warmup */ 
    94106    pool_test_pool(); 
    95107    pool_test_malloc_free(); 
     
    118130    } 
    119131 
    120     PJ_LOG(4, (THIS_FILE, "..LOOP count:                        %u", LOOP)); 
    121     PJ_LOG(4, (THIS_FILE, "..number of alloc/dealloc per loop:  %u", COUNT)); 
    122     PJ_LOG(4, (THIS_FILE, "..pool allocation/deallocation time: %u", pool_time)); 
    123     PJ_LOG(4, (THIS_FILE, "..malloc/free time:                  %u", malloc_time)); 
    124     PJ_LOG(4, (THIS_FILE, "..pool again, second invocation:     %u", pool_time2)); 
     132    PJ_LOG(4,(THIS_FILE,"..LOOP count:                        %u",LOOP)); 
     133    PJ_LOG(4,(THIS_FILE,"..number of alloc/dealloc per loop:  %u",COUNT)); 
     134    PJ_LOG(4,(THIS_FILE,"..pool allocation/deallocation time: %u",pool_time)); 
     135    PJ_LOG(4,(THIS_FILE,"..malloc/free time:                  %u",malloc_time)); 
     136    PJ_LOG(4,(THIS_FILE,"..pool again, second invocation:     %u",pool_time2)); 
    125137 
    126138    if (pool_time2==0) pool_time2=1; 
     
    130142        best = pool_time2, worst = pool_time; 
    131143 
    132     PJ_LOG(3, (THIS_FILE, "..malloc Speedup best=%dx, worst=%dx",  
     144    PJ_LOG(3, (THIS_FILE, "..pool speedup over malloc best=%dx, worst=%dx",  
    133145                          (int)(malloc_time/best), 
    134146                          (int)(malloc_time/worst))); 
Note: See TracChangeset for help on using the changeset viewer.