# How does function inlining reflect on the profiling output?

**URL:** <https://discourse.julialang.org/t/how-does-function-inlining-reflect-on-the-profiling-output/70471>\
**Category:** Performance\
**Tags:** profiling\
**Created:** [October 27, 2021, 10:58am UTC](https://discourse.julialang.org/t/how-does-function-inlining-reflect-on-the-profiling-output/70471 "2021-10-27T10:58:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 27, 2021, 10:58am UTC](https://discourse.julialang.org/t/how-does-function-inlining-reflect-on-the-profiling-output/70471/1 "2021-10-27T10:58:20Z")

</div>

I have a Julia program. It includes a big function which calls another, small, function in two places.  
Profiling the execution and displaying a flame graph with ProfileView shows that most of the time is spent in the small function.  
So I wonder, if a function appears in the profiling output, does that mean that it wasn’t inlined? In other words, how are inlined functions accounted for in profiling?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 28, 2021, 9:46am UTC](https://discourse.julialang.org/t/how-does-function-inlining-reflect-on-the-profiling-output/70471/2 "2021-10-28T09:46:23Z")

</div>

Here’s a demo that should answer your questions:

```julia
julia> function f()
           inline_me()
           dont_inline_me()
       end
       inline_me() = sleep(0.1)
       @noinline dont_inline_me() = sleep(0.1)
dont_inline_me (generic function with 1 method)

julia> using Profile

julia> @profile f()

julia> using ProfileView

julia> ProfileView.view()
Gtk.GtkWindowLeaf(name="", parent, width-request=-1, height-request=-1, visible=TRUE, sensitive=TRUE, app-paintable=FALSE, can-focus=FALSE, has-focus=FALSE, is-focus=FALSE, focus-on-click=TRUE, can-default=FALSE, has-default=FALSE, receives-default=FALSE, composite-child=FALSE, style, events=0, no-show-all=FALSE, has-tooltip=FALSE, tooltip-markup=NULL, tooltip-text=NULL, window, opacity=1.000000, double-buffered, halign=GTK_ALIGN_FILL, valign=GTK_ALIGN_FILL, margin-left, margin-right, margin-start=0, margin-end=0, margin-top=0, margin-bottom=0, margin=0, hexpand=FALSE, vexpand=FALSE, hexpand-set=FALSE, vexpand-set=FALSE, expand=FALSE, scale-factor=1, border-width=0, resize-mode, child, type=GTK_WINDOW_TOPLEVEL, title="Profile", role=NULL, resizable=TRUE, modal=FALSE, window-position=GTK_WIN_POS_NONE, default-width=800, default-height=600, destroy-with-parent=FALSE, hide-titlebar-when-maximized=FALSE, icon, icon-name=NULL, screen, type-hint=GDK_WINDOW_TYPE_HINT_NORMAL, skip-taskbar-hint=FALSE, skip-pager-hint=FALSE, urgency-hint=FALSE, accept-focus=TRUE, focus-on-map=TRUE, decorated=TRUE, deletable=TRUE, gravity=GDK_GRAVITY_NORTH_WEST, transient-for, attached-to, has-resize-grip, resize-grip-visible, application, is-active=TRUE, has-toplevel-focus=TRUE, startup-id, mnemonics-visible=FALSE, focus-visible=FALSE, is-maximized=FALSE)

julia> ./REPL[1]:5, inline_me [inlined]
./REPL[1]:6, MethodInstance for dont_inline_me()

```

The last two lines come from left-clicking on bars in the flamegraph:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/d/8dc00d8a2f2e27a76ee81cab261040b98453e57c.png)

You can see one is annotated `[inlined]`, but nevertheless shows up with its own separate (fake) bar. In other words, we’ve worked hard to lie to you 🙂 but it’s generally more useful that way (inlining is a compiler optimization and doesn’t affect the actual writing of code).
