Open nsf opened 8 years ago
@nsf I feel like channels are more idiomatic for communicating. @atemerev Do you believe these benchmarks should be a performance free for all pulling out all of the stops or should each language implementation strive to be idiomatic? Something in between?
I'm not implying that my version should be used instead of the one repo has. I just wrote it out of curiosity and sharing it here.
@nsf Awesome! Thanks for sharing it with everyone. I wasn't trying to attack, just wanted to clarify and help improve the benchmark.
Also you might want to include language versions in benchmark results
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
start := time.Now()
var wg sync.WaitGroup
wg.Add(1)
var result int
go skynet(&result, 0, 1000000, 10, &wg)
wg.Wait()
took := time.Since(start)
fmt.Printf("Result: %d in %d ms.\n", result, took.Nanoseconds()/1e6)
}
Just in case if you're curious. It avoids using channels for communications and uses sync.WaitGroup instead. Results are collected via arrays and then aggregated inside a single goroutine. On my machine it's slightly faster than channel-based one.