Hi joppez, For stackless coroutines, the context switch has no cost For stackful coroutines (NimGo), the context switch is very cheap (my machine gave me 50ns on a little test) using assembly code, but can be slower when using other methods (like fibers or ucontext). For threads, the context switch is also very cheap (my machine gave me 85ns on a little test)
However, in a whole program, the context switch time is not what takes the most time. For threads, synchronization with locks can be very costly. Atomics are cheaper, but still have a little overhead. What is most interesting with coroutines is that you are not limited by system resources and memory usage is typically lower (and memory can really slow down the whole program is threads or coroutines are not recycled).