On Mon, Jul 8, 2024 at 10:36 PM Robert Engels <rob...@me.com> wrote:
> Is there anyway to do what I want? The usual way is to factor out any parts that can skew the results before the benchmark loop and call b.ResetTimer() just before entering the 'for i := 0; i < b.N; i++ {' loop. > If not, maybe a useful addition, see > https://javadoc.io/doc/org.openjdk.jmh/jmh-core/latest/org/openjdk/jmh/annotations/OperationsPerInvocation.html > for a similar Java api. I don't think it's useful. The testing package does IMO the right thing. The task of the benchmark loop is to always do the same unit/amount of work b.N times. Only then it all together makes sense and can produce meaningful data about the unit/amount. It follows that measuring O(b.N^2) algorithms cannot work very well. But you can often measure b.N times a O(K^2) work using a constant K. -- 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/CAA40n-X9ZC%3D9KczP%3D49QUKxyRcSkGL1RSScxd%3Dr02PEEuUtCgw%40mail.gmail.com.