Understood. Is there anyway to do what I want? If not, maybe a useful addition, see https://javadoc.io/doc/org.openjdk.jmh/jmh-core/latest/org/openjdk/jmh/annotations/OperationsPerInvocation.html <https://javadoc.io/doc/org.openjdk.jmh/jmh-core/latest/org/openjdk/jmh/annotations/OperationsPerInvocation.html> for a similar Java api.
The reason this is helpful, is that some algorithms will degrade on subsequent (e.g. the first order insertion is really fast, but they get slower and slower because the dev used an O(n^2) design - a test that only goes to b.N may not hit it. It is also useful when comparing performance metrics for operations like these across languages (similar testing framework in a non-Go language). So you need to be able to test the add operation but calculate the average time per op across the test with a minimum number of elements. Is there any canonical way of doing this? > On Jul 8, 2024, at 3:22 PM, Jan Mercl <0xj...@gmail.com> wrote: > > On Mon, Jul 8, 2024 at 10:08 PM 'Robert Engels' via golang-nuts > <golang-nuts@googlegroups.com> wrote: > >> Given this code (which I know is not “correct”): > > Setting b.N in the benchmark code has no specified behavior. The > actual behavior at the moment ignores such changes. > > The algorithm used by the testing package adjusts b.N in an attempt to > stabilize the results under certain conditions. Ignoring this guidance > makes all attempts of that algorithm futile. And as it assumes the > benchmark body was executed b.N times anyway, it computes garbage. > > -- > 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-UK65F%3DNp%2BkS59w_y-G%2BSQeFoh5V9b8Ezgt9TkGuzx-7g%40mail.gmail.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/E13E028C-9962-4D74-9D19-3615303CB6ED%40me.com.