Just for fun and possibly to give us some facts to inform API design decisions, I wrote some micro-benchmarks using Hugo Duncan's excellent Criterium library to test the performance of different method calling conventions.
It's an artificial micro-benchmark clearly, so usual caveats apply.
Preliminary conclusions:
- Primitive functions and Java interface calls using primitives are fastest (around 2 ns)
- Boxed regular functions, boxed Java interface calls and pre-defined protocol calls are next (around 8ns)
- Protocol calls that have been extended are a bit slower, but still pretty fast (around 14 ns)
- A multi-method that dispatches on class is quite a bit slower (around 90 ns)
- A multi-method that double-dispatches on [(class a) (class b)] is *much* slower (around 230 ns)
- Reflection really sucks..... (9000 ns)
My takeaway from all this is that we are right to focus on using protocols as the primary dispatch mechanism.