Revised results using the same input data for each iteration without a copy just a Filter function.
i7-7500U name time/op Filter3-4 2.29µs ± 0% Filter4-4 1.51µs ± 0% i5-8250U name time/op Filter3-8 2.30µs ± 0% Filter4-8 1.53µs ± 0% Peter On Wednesday, July 7, 2021 at 11:25:11 AM UTC-4 [email protected] wrote: > It is found that the test file is not written correctly. > The filtered data should be reset in each loop. > The corrected one: https://play.golang.org/p/yJMweZLIXAz > <https://t.co/dZUGrAQ1cB?amp=1> > > ;D > > On Monday, June 7, 2021 at 10:57:19 AM UTC-4 [email protected] wrote: > >> >> The code: https://play.golang.org/p/DxUj6kBqf8k >> >> The Filter4 function has one more assignment statement than Filter3. >> But the benchmark result shows Filter4 is faster than Filter3. >> >> The result: >> >> cpu: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz >> BenchmarkFilter3-4 3575656 980.2 ns/op 0 >> B/op 0 allocs/op >> BenchmarkFilter4-4 3956533 916.8 ns/op 0 >> B/op 0 allocs/op >> >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/da1cc2bd-a54d-402a-ac0d-9f7300dbd207n%40googlegroups.com.
