# Identical functions repeated benchmarks show systematic differences

**URL:** <https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345>\
**Category:** Performance\
**Tags:** question, sort\
**Created:** [July 27, 2021, 4:08am UTC](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345 "2021-07-27T04:08:27Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [July 27, 2021, 6:09pm UTC](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345/13 "2021-07-27T18:09:18Z")

</div>

> [@Lilith](#):
>
> I’m beginning to suspect something along the lines of when these two semantically identical functions are compiled, one of them gets advantaged somehow in a measurable way.

This doesn’t have anything to do with one function being advantaged over another, it’s probably the abstraction(s) of technologies your computer uses leaking up the stack.

When code is compiled, it’s placed somewhere in memory. Depending on where it’s placed, it can be accessed faster or slower (e.g. because it’s placed closer to where the benchmarking code resides). This isn’t something that’s exposed through julia and hence the abstraction of the julia runtime/context of execution is leaking that low level detail of how code is placed in and loaded from memory (and maybe looked up during benchmarking as well). I’m almost certain if you place `HopeRollSort1Alg` _after_ `HopeRollSort2Alg`, you could sometimes observe that `HopeRollSort2Alg` is faster.

At the moment, julia does not try to reorder compiled code based on how often it’s called, as far as I know.

If you know where and how to look, you can find these kinds of leaky abstractions all over the place - and how [Joel Spolsky put it](https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/):

> **All non-trivial abstractions, to some degree, are leaky.**

---

_[View the full topic](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345)._
