I'd like to quickly suggest that the "filtering without allocating"
technique from this page is probably what you want and you may want to
consider if/why you even need to benchmark this:
https://github.com/golang/go/wiki/SliceTricks
However, if you do need to benchmark it:
On Wed, Mar 18, 2020, at 11:46, Orson Cart wrote:
> - if the profiler were to call the function 1000 times, only the first
> call will have done any actual work. To make the benchmarked function
> do the same work each time we'd have to set up fresh data for each
> call to the function. We can do that but we don't want that setup to
> show in the timing for the benchmark.
>
> Does anyone know of a solution to this?
Just call b.ResetTimer() after setting up your data:
https://godoc.org/testing#B.ResetTimer
—Sam
--
Sam Whited