density
C++11 library for paged memory management, function queues, heterogeneous queues and lifo memory management

Benchmarks of the function queues


In this single-thread tests all the function queues of density are compared to a std::vector and a std::queue of std::functions. In every test a function queue is created, filled by many trivial functions, and then all the functions are consumed on-by-one. Only in the case of std::vector the queue is cleared in one time, rather than removing the functions one by one while they are invoked. This is because there is no constant-time function to remove the first element of a std::vector.

In the first test the function queues of density are instantiated with the default template parameters. In the second test they exploit all the available optimizations, that is:

Summary of the results

All the tests are compiled with Visual Studio 2017 (version 15.1), and executed on Windows 10 with an int Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz, 2808 Mhz, 4 cores, 8 logical processors. The benchmarks of the whole library are shuffled and interleaved at the granularity of a single invocation with a given cardinality, and every invocation occurs 8 times.

Even unnecessarily paying the cost of multithreading, concurrent function queues are in general better than std::queue of std::function. lf_function_queue is much faster in the case of single consumer and single producers, as it can reduce considerably the number of atomic memory operations.

Results of the first test

func_queue_st_b1.png

Results of the second test

func_queue_st_b2.png