I have a function that logs messages. When I run this function with and without the go keyword, I observe the following:
With Goroutines:
I start a timer (using the time package).
After 45 seconds, I get 20,000 logs.
Without Goroutines:
I remove the go keyword.
I run the same function and get 20,000 logs in 45 seconds.
Benchmark Results:
I wrote benchmarks for both implementations, and the benchmarks indicate that the ns/op (nanoseconds per operation) is significantly lower for the goroutine-based implementation compared to the non-concurrent one.
Issue:
Despite the benchmark results, when I run the actual project with a timer, both implementations (with and without goroutines) produce the same number of logs (60,000) in the same amount of time (45 seconds).