4 ms·
Don't underestimate the time cost of coroutining (literally goroutining, and using a channel, or to-and-fro with HasNext and Next). And the unfinished generator
by JulianMorrison 13y ago
Don't underestimate the time cost of coroutining (literally goroutining, and using a channel, or to-and-fro with HasNext and Next). And the unfinished generator is using memory, too. Code runs fastest when it can sit in cache, so creating a slice in a tight loop and returning it is probably optimal if the actual data you just materialized is small.
- yoklov 13y agoSure, it's better than the goroutine approach, but that doesn't say much. It becomes quite suboptimal if you have a large amount of data. I also think that you're likely underestimating the cost of the additional memory allocations.