Given this code (which I know is not “correct”):

func BenchmarkOrders(b *testing.B) {
    var ob = orderBook{}
    var inst = Equity{}
    var ex = testExchangeClient{}

    const N_ORDERS = 1000000

    b.ResetTimer()

    b.N = N_ORDERS

    for i:=0;i<N_ORDERS;i++ {
        var o1 = LimitOrder(inst, Buy, NewDecimal("100"), NewDecimal("10"))
        o1.ExchangeId = fmt.Sprint(i)
        var s1 = sessionOrder{ex, o1, time.Now()}
        ob.add(s1)
    }
    for i:=0;i<N_ORDERS;i++ {
        var o1 = LimitOrder(inst, Sell, NewDecimal("100"), NewDecimal("10"))
        o1.ExchangeId = "S"+fmt.Sprint(i)
        var s1 = sessionOrder{ex, o1, time.Now()}
        ob.add(s1)
    }

}

Instead of setting b.N, is there a better way to get a “benchmark” for the 
logical operation.

In this case, the number of operations is 2 * N_ORDERS, so I would like to time 
the entire process and output in the benchmark format the time per “op”.

It seems to work setting b.N, but I’m sure this isn’t ideal.

In Java JMH, you have the ability to set the “number of operations” performed 
during the test - I’m looking for something similar.

-- 
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/E5D80591-F819-4C4D-9E18-6E2438B269FB%40me.com.

Reply via email to