2014/1/14 Oliver Kowalke
I believe you can't and shouldn't compare fibers with qthreads, TBB or openmp. I'll write a test measuring the overhead of a fiber running in one thread (as already described above) first.
How about comparing fiber construction and joining with thread construction and joining? This will help the users to decide, is it beneficial to start a new thread or to start a fiber. A few ideas for tests: * compare construction+join of a single thread and construction+join of single fiber (empty functors in both cases) * compare construction+join of a multiple threads and construction+join of multiple fibers (empty functors in both cases) * compare construction of a thread and construction of fiber (empty functors in both cases) Pseudocode: void foo(){} const unsigned N = 1000; // Test #1 timer start for (unsigned i = 0; i < N; ++i) { fiber f(&foo); f.join(); } cout << "Fibers: " << timer stop; timer start for (unsigned i = 0; i < N; ++i) { boost::thread f(&foo); f.join(); } cout << "Threads: " << timer stop; // Test #2 timer start for (unsigned i = 0; i < N; ++i) { fiber f1(&foo), f2(&foo), f3(&foo), f4(&foo), f5(&foo); f1.join(); f2.join(); f3.join(); f4.join(); f5.join(); } cout << "Fibers: " << timer stop; timer start for (unsigned i = 0; i < N; ++i) { boost::thread f1(&foo), f2(&foo), f3(&foo), f4(&foo), f5(&foo); f1.join(); f2.join(); f3.join(); f4.join(); f5.join(); } cout << "Threads: " << timer stop; // Test #3 timer start for (unsigned i = 0; i < N; ++i) { fiber(&foo).detach(); } cout << "Fibers: " << timer stop; timer start for (unsigned i = 0; i < N; ++i) { boost::thread(&foo).detach(); } cout << "Threads: " << timer stop; -- Best regards, Antony Polukhin