# Compiling to branch table

**URL:** <https://discourse.julialang.org/t/compiling-to-branch-table/16599>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 21, 2018, 1:12pm UTC](https://discourse.julialang.org/t/compiling-to-branch-table/16599 "2018-10-21T13:12:54Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [December 29, 2018, 5:51am UTC](https://discourse.julialang.org/t/compiling-to-branch-table/16599/19 "2018-12-29T05:51:13Z")

</div>

You seem to be using the 64 bit packed arrays in that last benchmark, which are 8 times smaller than the original arrays, hence your code is ~8 times faster.

By the way, a lot of interesting discussion spawned from this question, including [this topic](https://discourse.julialang.org/t/psa-microbenchmarks-remember-branch-history/17436) which suggests that we should have been using larger vectors in these benchmarks. For 100k vectors, I get these timings:

```julia
julia> src = rand(1:16, 100_000);

julia> dst = similar(src);

julia> broadcast!($findcode, $dst, $src);
  510.262 μs (0 allocations: 0 bytes)

julia> broadcast!($findcode3, $dst, $src);
  637.381 μs (0 allocations: 0 bytes)

julia> broadcast!($findcode_lookuptable, $dst, $src);
  398.854 μs (0 allocations: 0 bytes)

```

So indeed the original solution seems to be faster than the accepted solution (but not as fast as a look-up-table), and much more readable IMO.

---

_[View the full topic](https://discourse.julialang.org/t/compiling-to-branch-table/16599)._
