I'm not going to argue with anyone about the fucking confusing concepts of thread, coroutine and fiber. I call them all coroutines. They can be classified by stack, scheduler or threads.
- Rewrite CMakeLists.txt to find brpc in system library.
- Design benchmark for stackful and stackless seperately.
pthread | bthread | libco | cpp20co | libgo | |
---|---|---|---|---|---|
create | ✅ | ✅ | ✅ | ✅ | ✅ |
join | ✅ | ✅ | 🈚️ | 🈚️ | ✅ |
resume | 🈚️ | 🈚️ | ✅ | ✅ | 🈚️ |
multiply 1 | ✅ | ✅ | ✅ | ✅ | ✅ |
multiply 1M | ✅ | ✅ | ✅ | ✅ | ✅ |
ctx switch single-thread | ✅ | ✅ | ✅ | ✅ | ✅ |
ctx switch multi-thread | ✅ | ✅ | 🈚️ | 🈚️ | ✅ |
- bthread:
bthread_start_urgent
- libgo:
go
andyield
⚠️ Since I haven't figured out how to write the CMakeLists.txt for projects with brpc, current build configurations of this project are taken fromincubator-brpc/example/echo_c++
. Thus this project can only be place on the same dir. This will be fix as soon as possible.
⚠️ Different benchmarks can be switched by modifyingmain()
inbenchmark.cpp
. Command line support will be added soon.
- Install all libraries into default system path except brpc. CMake looks up the libraries in default path.
- Clone and compile brpc according to official tutorial.
- Clone this project into brpc's example dir.
cd incubator-brpc/example git clone [email protected]:TKONIY/ThreadBenchmark.git
- Modify
main()
inbenchmark.cpp
. One benchmark of all libraries will be provided in one build. - Build the project.
cd ThreadBenchmark
mkdir build
cd build
cmake ..
cmake --build .
- All executable will be provided in
build/
like this:
build
├── benchmark_bthread
├── benchmark_cpp20co
├── benchmark_libco
├── benchmark_libgo
└── benchmark_pthread
- Just simply execute the binary files.
./benchmark_cpp20co