The test package has methods to disable the timing - wrap the setup in these.
> On Mar 18, 2020, at 10:50 AM, Sam Whited <s...@samwhited.com> wrote: > > 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 > > -- > 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 golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/6b8fcaa6-0c14-4e9c-8a22-71b9154dac7a%40www.fastmail.com. -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/E5FE528A-7769-4E8C-9D7D-C48ACF5726F5%40ix.netcom.com.