# Performance drawback with subtyping

**URL:** <https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939>\
**Category:** Performance\
**Created:** [December 16, 2020, 4:02pm UTC](https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939 "2020-12-16T16:02:42Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![Ronneesley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronneesley/32/11072_2.png) [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Post date:** [December 17, 2020, 12:36am UTC](https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939/14 "2020-12-17T00:36:15Z")

</div>

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.

---

_[View the full topic](https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939)._
