# Why is this code slow?

**URL:** <https://discourse.julialang.org/t/why-is-this-code-slow/24403>\
**Category:** General Usage\
**Created:** [May 20, 2019, 2:21pm UTC](https://discourse.julialang.org/t/why-is-this-code-slow/24403 "2019-05-20T14:21:17Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [May 20, 2019, 3:58pm UTC](https://discourse.julialang.org/t/why-is-this-code-slow/24403/4 "2019-05-20T15:58:12Z")

</div>

CF [PSA: Microbenchmarks remember branch history](https://discourse.julialang.org/t/psa-microbenchmarks-remember-branch-history/17436)

It is even worse here, since your cdf does not fit into L1. You can probably get a significant speedup by using a cache-oblivious layout of the implicit search tree, instead of a linearly ordered vector.

Unfortunately, I am not aware of any julia packages implementing search-optimized layout of sorted lists.

---

_[View the full topic](https://discourse.julialang.org/t/why-is-this-code-slow/24403)._
