Thanks for point it out Brian. I must of had some background interference. I 
re-ran the tests, Go was the same, Java is

Benchmark                           Mode  Cnt     Score    Error  Units
TestJavaDispatch.TestArrayDispatch  avgt    9  4367.196 ± 50.227  ns/op
TestJavaDispatch.TestDispatch       avgt    9     0.942 ±  0.005  ns/op
TestJavaDispatch.TestIDispatch      avgt    9     1.341 ±  0.040  ns/op

So the error is much less.

> On Jun 21, 2024, at 2:14 PM, Robert Engels <reng...@ix.netcom.com> wrote:
> 
> Yep. Haven’t dig into it. I assume it has to do with allocations. That it is 
> 2x faster than Go is somewhat suspect as well. 
> 
> I was more sharing for the change in Go performance. 
> 
>> On Jun 21, 2024, at 2:11 PM, 'Brian Candler' via golang-nuts 
>> <golang-nuts@googlegroups.com> wrote:
>> 
>> > 4775.994 ± 13310.309
>> 
>> Those are pretty wide error bars though...
>> 
>> On Friday 21 June 2024 at 17:15:05 UTC+1 Robert Engels wrote:
>> I had the opportunity to revisit my interface dispatch benchmark 
>> (https://github.com/robaho/go-dispatch-test 
>> <https://github.com/robaho/go-dispatch-test>).
>> 
>> Previously, the dispatching using pointer receivers was nearly 3x slower 
>> (i.e. 5.5 ns to 12.6 ns):
>> 
>> goos: darwin
>> goarch: amd64
>> pkg: github.com/robaho/go-dispatch-test 
>> <http://github.com/robaho/go-dispatch-test>
>> BenchmarkIDispatch-8        300000000            5.56 ns/op
>> BenchmarkDispatch-8         2000000000           1.57 ns/op
>> BenchmarkArrayParms-8         200000          9265 ns/op
>> PASS
>> 
>> and
>> 
>> goos: darwin
>> goarch: amd64
>> pkg: github.com/robaho/go-dispatch-test 
>> <http://github.com/robaho/go-dispatch-test>
>> BenchmarkIDispatch-8    100000000           12.6 ns/op
>> BenchmarkDispatch-8     2000000000           1.57 ns/op
>> PASS
>> 
>> 
>> With the latest Go 1.22.4, the performance difference has reversed ! (tests 
>> have been combined for simplicity).
>> 
>> goos: darwin
>> goarch: amd64
>> pkg: github.com/robaho/go-dispatch-test 
>> <http://github.com/robaho/go-dispatch-test>
>> cpu: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
>> BenchmarkIDispatch-8        535263746            2.118 ns/op
>> BenchmarkIDispatchPtr-8     675721244            1.773 ns/op
>> BenchmarkDispatch-8         1000000000           0.6953 ns/op
>> BenchmarkArrayParms-8         184212          6440 ns/op
>> PASS
>> 
>> Pretty impressive work. The interface based dispatch is almost equal to the 
>> Java version now:
>> 
>> Benchmark                           Mode  Cnt     Score       Error  Units
>> TestJavaDispatch.TestArrayDispatch  avgt    3  4775.994 ± 13310.309  ns/op
>> TestJavaDispatch.TestDispatch       avgt    3     0.941 ±     0.088  ns/op
>> TestJavaDispatch.TestIDispatch      avgt    3     1.331 ±     0.146  ns/op
>> 
>> -- 
>> 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>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/57b5e091-f309-4d5f-b102-f58c3d344776n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/57b5e091-f309-4d5f-b102-f58c3d344776n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> 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>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/6E7B8F20-45AE-462F-85FD-7A30A77806C7%40ix.netcom.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/6E7B8F20-45AE-462F-85FD-7A30A77806C7%40ix.netcom.com?utm_medium=email&utm_source=footer>.

-- 
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/D940D5A5-7313-4E2F-B048-E32AA6B402BE%40ix.netcom.com.

Reply via email to