Please kindly advise on benchmarks used to test a C and C++ allocator? Benchmarks satisfying any of the following aspects are considered:
- Speed
- Fragmentation
- Concurrency
Thanks!
Please kindly advise on benchmarks used to test a C and C++ allocator? Benchmarks satisfying any of the following aspects are considered:
Thanks!
You can download
nedmalloc
and try to compare your allocator with it. It has a test calledtest.c
with the source code, which you can rewrite according to your allocator.I tested several allocators myself a few years ago and my experience is that the results all depend on the kind of test. If you want to write some benchmarks yourself, consider the following situations:
You will notice that the results will be different for every test. Allocators that are very good in one situation, may be bad in other situations.
In practice this means that it's best to test it in your application, in a live/realistic situation.
If you ask about a general allocator for a C/C++ program then I have found this paper Hoard: A Scalable Memory Allocator for Multithreaded Applications which considers this question. This is a quote from this document
This paper is sort of old. However I have seen recently an allocator for HP-UX (MallocNextGen) and HP also can't ensure that it is good for all possible applications. It says:
As for speed and concurrency my own experience is that you have to measure performance of your own program in order to compare two different allocators. If we talk about Linux you can use LD_PRELOAD in order to load different allocators.