No, think about it... If the setup time is 1 minute per iteration, and the timed activity is 1 usec per iteration, then in order to time for 1 second the test would need to run for a million minutes….
You need to restructure the test to avoid the setup on every test invocation. > On Oct 22, 2018, at 10:36 AM, Sathish VJ <sathis...@gmail.com> wrote: > > So, I also tried with > go test -v -bench=. -test.benchtime=0.1s > and that does complete. > > But is the implication that StopTimer/StartTimer is too costly to use even > for this simple benchmark? > > On Monday, 22 October 2018 21:00:20 UTC+5:30, Jan Mercl wrote: > > > > On Mon, Oct 22, 2018 at 5:21 PM Sathish VJ <sath...@gmail.com <>> wrote: > > I believe it does actually end, it's just the timeout kicks in sooner. > > The testing package attempts to make the benchmark run for at least 1 sec by > default, IINM. Your code has two parts. The measured one is like 1 nsec. The > non-measured is tens of microseconds or more. Meaning that for every 1 nsec > measured the code spends several thousans times more in the non-measured > path. So 1 sec / 1 nsec * theOverheadRatio is the time to read 1 sec of > _measured time. > > -- > -j > > > -- > 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 > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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. For more options, visit https://groups.google.com/d/optout.