# Curious about the internals of dynamic dispatch

**URL:** https://discourse.julialang.org/t/curious-about-the-internals-of-dynamic-dispatch/102888
**Category:** Performance
**Created:** [August 17, 2023, 1:04am UTC](https://discourse.julialang.org/t/curious-about-the-internals-of-dynamic-dispatch/102888 "2023-08-17T01:04:07Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![HashBrown](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hashbrown/32/43601_2.png) [@HashBrown](https://discourse.julialang.org/u/HashBrown)
#### Post date: [August 17, 2023, 3:34am UTC](https://discourse.julialang.org/t/curious-about-the-internals-of-dynamic-dispatch/102888/13 "2023-08-17T03:34:14Z")

</div>

Hmm, I noticed that my types are of the same size so there is a concern of some optimization there. I changed B to also contain a Float64/f64.

Now we have Julia:

```julia
Dynamic Dispatch:
  4.673 ms (0 allocations: 0 bytes)
Static Dispatch
  256.708 μs (0 allocations: 0 bytes)

```

and Rust:

```julia
dynamic dispatch time: [4.4012 ms 4.4029 ms 4.4048 ms]
                        change: [+361.64% +362.24% +362.81%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high severe

static dispatch time: [260.19 µs 260.35 µs 260.53 µs]
                        change: [+172.74% +173.19% +173.81%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 7 outliers among 100 measurements (7.00%)
  1 (1.00%) high mild
  6 (6.00%) high severe

```

Looks like they match up pretty closely now. The point of dictionary lookup vs array lookup is a good one. I suppose Julia is forced to be a little slower on that front to allow for extra flexibility

---

_[View the full topic](https://discourse.julialang.org/t/curious-about-the-internals-of-dynamic-dispatch/102888)._
