Exemple #1
0
int main(int argc, char** argv)
{
    deal_with_test_count(argc, argv);

    pool = xmem_create_pool(sizeof(test_struct));

    uint64_t total_start, alloc_start, free_start;

    total_start = alloc_start = rdtsc();
    for(int i = 0; i < test_count; i++)
    {
        test_array[i] = (test_struct*)xmem_alloc(pool);
    }
    alloc_total = rdtsc() - alloc_start;

    free_start = rdtsc();
    for(int i = 0; i < test_count; i++)
    {
        xmem_free(pool, (char*)test_array[i]);
    }
    free_total = rdtsc() - free_start;
    xmem_destroy_pool(pool);

    total = rdtsc() - total_start;

    printf("=== perf of xmem\n");
    printf("alloc & free times: %d\n", test_count);
    printf("alloc time: %llu CPU cycles\n", alloc_total);
    printf("free time: %llu CPU cycles\n", free_total);
    printf("total time: %llu CPU cycles\n", total);

    return 0;
}
Exemple #2
0
int main()
{
    pool = xmem_create_pool(sizeof(test_struct));

    int total_start, alloc_start, free_start;

    total_start = alloc_start = rdtsc();
    for(int i = 0; i < TEST_COUNT; i++)
    {
        test_array[i] = xmem_alloc(pool);
    }
    alloc_total = rdtsc() - alloc_start;

    free_start = rdtsc();
    for(int i = 0; i < TEST_COUNT; i++)
    {
        xmem_free(pool, test_array[i]);
    }
    free_total = rdtsc() - free_start;
    xmem_destroy_pool(pool);

    total = rdtsc() - total_start;

    printf("=== perf of xmem\n");
    printf("alloc & free times: %d\n", TEST_COUNT);
    printf("alloc time: %d CPU cycles\n", alloc_total);
    printf("free time: %d CPU cycles\n", free_total);
    printf("total time: %d CPU cycles\n", total);

    return 0;
}