# A couple questions on profiling

**URL:** <https://discourse.julialang.org/t/a-couple-questions-on-profiling/35290>\
**Category:** General Usage\
**Created:** [February 28, 2020, 4:31pm UTC](https://discourse.julialang.org/t/a-couple-questions-on-profiling/35290 "2020-02-28T16:31:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![riccardomurri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/riccardomurri/32/8002_2.png) [@riccardomurri](https://discourse.julialang.org/u/riccardomurri)\
**Post date:** [February 28, 2020, 4:31pm UTC](https://discourse.julialang.org/t/a-couple-questions-on-profiling/35290/1 "2020-02-28T16:31:15Z")

</div>

I am trying to profile a piece of code that runs for about 15 minutes.

If I use the default settings in `Profile.init()`, the profile buffer fills up when Julia is still compiling my code, so I don’t get any useful information.

1. I guess I should use `Profile.init(n=...)` with a higher `n` than the default. But what is the default? And how much memory should I budget? (i.e., how much would the buffer approximately consume if I set `n=100_000`?)

2. Is it possible to save the profiling buffer in a file for later inspection?

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![riccardomurri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/riccardomurri/32/8002_2.png) [@riccardomurri](https://discourse.julialang.org/u/riccardomurri)\
**Post date:** [February 28, 2020, 4:51pm UTC](https://discourse.julialang.org/t/a-couple-questions-on-profiling/35290/2 "2020-02-28T16:51:34Z")

</div>

Just found the answer to my last question here: [Julia Profiling Cheat Sheet - Thirld Word Blog](https://thirld.com/blog/2015/05/30/julia-profiling-cheat-sheet/) (look for section " Trick: Saving profile results to disk")

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [February 28, 2020, 5:03pm UTC](https://discourse.julialang.org/t/a-couple-questions-on-profiling/35290/3 "2020-02-28T17:03:09Z")

</div>

The other thing I would suggest is finding a similar input on which your coffee only takes about a minute. Even if it’s not fully representative, the increased iteration speed will make improving things faster.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 29, 2020, 7:01am UTC](https://discourse.julialang.org/t/a-couple-questions-on-profiling/35290/4 "2020-02-29T07:01:53Z")

</div>

It’s not documented, but see [the code](https://github.com/JuliaLang/julia/blob/6dd9f418ef308a602582778bc6e413f0f57abc47/stdlib/Profile/src/Profile.jl#L49). Specifically,

```julia
julia> Int(ccall(:jl_profile_maxlen_data, Csize_t, ()))
1000000

```

It would be great to

1. have this documented (possibly by factoring out this code and `$(...)`ing it into the docstring, or defining a constant),
2. improve the interface by adding a higher-level argument the user can provide. frequently what one wants is not a buffer for `n` samples, but “just large enough for this much runtime”, and then the API could figure it out.

Please open an issue.
