Performance drawback with subtyping

I agree with you @lmiq, we should study a more realistic case. So I apply the sin function as you did and changed n = 100,000,000. Because with a little n there is a big influencial of processes at operation system.

My results was:

  • with dynamic dispatch: 1.120 s (0 allocations: 0 bytes)
  • with splitting: 1.121 s (0 allocations: 0 bytes)
  • with functors: 1.144 s (0 allocations: 0 bytes)
  • with cast: 1.159 s (0 allocations: 0 bytes)
  • simple sum of an array of Float64 of same size: 504.909 ms (0 allocations: 0 bytes)

true

I think, the difference must be related with getfield function, that is reasonable.

So, I think we can conclude that: although the warning with @code_warntype, the performance is good with dynamic dispatch.

1 Like