I’m making an update of the benchmarks I had ran back in 2015, comparing the performance of Julia dispatch on single argument against C++ dispatch: https://groups.google.com/forum/#!topic/julia-users/pTywc8Lcd28
The code is in here: https://github.com/cdsousa/SingleDispatchJuliaVsCXX.
Output of C++:
concr 0.001477 seconds abstr 0.007114 seconds (sum=500000500000)
Output of Julia Nighty (0.7.0-DEV.2587):
concr 0.000758 seconds abstr 0.027950 seconds (999.49 k allocations: 15.251 MiB) manual dispatch 0.007648 seconds union 0.008517 seconds (sum=500000500000)
And output of Julia 0.6.1:
concr 0.000535 seconds abstr 0.030308 seconds (999.49 k allocations: 15.251 MiB) manual dispatch 0.008486 seconds union 0.037312 seconds (999.49 k allocations: 15.251 MiB, 24.76% gc time) (sum=500000500000)
concrmeans no dispatch (concrete type known at compile time)
abstrmeans dispatching from an abstract (base) type reference
manualmeans dispatching “by hand” using
elseblocks over the return of
unionmeans dispatching from a union of the two concrete types
I’m very happy with the times for the Union case! I think we can say it is almost on par with C++
Update: These times shall be taken with a (lot) grain of salt. See replies bellow.
Update 2: These times do not measure dispatching (at CUP instructions level) alone. They measure a possible algorithm structure using derivative types in more or less idiomatic approaches in two languages. As with almost all benchmarks, a lot of things counts for the timings: compilation optimizations (inlining), cache hittings, branch prediction, etc.
Update 3: See some new measures in replies below.