Re: [go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Marvin Renich
* Warren Bare [200519 13:53]: > OK, I added a sum of the rand to the demo code and the results are the > same. Since it is displaying the sum, it seems clear that the code is not > optimized away. > > Again, I am NOT trying to time each iteration of the loop. This is a > minimal

Re: [go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Michael Jones
as was explained, the loop needs to be "for i:=0; i < b.N; i++" as was mentioned, the compiler's dead code elimination efforts can frustrate benchmarking. they way to make sure the test code survives is to not let it be dead code. for example // external var dummy func for i:=0; i < b.N; i++ {