# Losing performance when adding function to a package?

**URL:** https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533
**Category:** New to Julia
**Created:** [April 25, 2019, 9:51pm UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533 "2019-04-25T21:51:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 25, 2019, 9:51pm UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533/1 "2019-04-25T21:51:05Z")

</div>

Hey guys!

Basically I have a function which I use to read data. If I use this function directly inside of Julia ie. by compiling it as a function directly, using BenchmarkTools it runs in about 350 ms, but if I put it into a package instead and then load this package, it takes 150 ms longer, so 500 ms.

This of course is not a huge difference, but still in theory about 1/3 performance loss. Could someone explain to me why this would happen?

Kind regards

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [April 25, 2019, 10:30pm UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533/2 "2019-04-25T22:30:34Z")

</div>

Could you give a self-contained example of a function demonstrating this property please?

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 26, 2019, 7:10am UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533/3 "2019-04-26T07:10:58Z")

</div>

Will try to do so later today, seems like it is not expected behaviour 🙂

Kind regards

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 26, 2019, 6:16pm UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533/4 "2019-04-26T18:16:34Z")

</div>

@non-Jedi, I uploaded my package to Github and then downloaded it from there and now I don’t experience any performance loss. Maybe some other error has occured, which I was not aware of at the time.

Regards

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [April 26, 2019, 7:37pm UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533/5 "2019-04-26T19:37:32Z")

</div>

It’s hard to say anything without an example. But in general, I would _not_ expect to see any change in performance when a function is moved into a module. If you do find such a case and can reproduce it, then you can certainly post it here: it might indicate a bug in Julia or some other mistake that would be worth correcting.

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 26, 2019, 7:49pm UTC](https://discourse.julialang.org/t/losing-performance-when-adding-function-to-a-package/23533/6 "2019-04-26T19:49:10Z")

</div>

If I come across the problem again I will let you guys on discourse now. Currently if any bug would exist it would be due to offline compilation of a package using “activate .” in pkg mode. That is the only difference as far as I can tell from using “add Githublink”

Kind regards
