Coloration Schemes

The output color of ProfileSVG can be customized with the functions provided by the FlameGraphs package. See the FlameGraphs docmentation for details.

Default scheme

ProfileSVG.view()

or

using FlameGraphs
ProfileSVG.view(FlameColors())
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407

The default scheme uses cycling colors to distinguish different stack frames, while coloring runtime dispatch "red" and garbage-collection "orange". The run-time dispatch (aka, dynamic dispatch, run-time method lookup, or a virtual call) often has a significant impact on performance.

Stack frame category

You can colorize the stack frames based on their category, or module-of-origin.

using FlameGraphs
ProfileSVG.view(StackFrameCategory())
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407

In the default StackFrameCategory scheme, "gray" indicates time spent in Core.Compiler (mostly inference), "dark gray" in other Core, "yellow" in LLVM, "orange" in other ccalls, "light blue" in Base, and "red" is uncategorized (mostly package code).

bgcolor and fontcolor options

ProfileSVG.view and ProfileSVG.save have optional keyword arguments for specifying the SVG styles.

The bgcolor option specifies the background color style and the fontcolor option specifies the font color style.

One of the following symbols is available for bgcolor:

  • :fcolor
    • fcolor(:bg) (default)
  • :classic
    • pale color gradation which comes from the original Flame Graphs
  • :transparent
    • fully transparent

One of the following symbols is available for fontcolor:

  • :fcolor
    • fcolor(:font) (default)
  • :classic
    • black
  • :currentcolor
  • :bw
    • black or white depending on the frame color
Info

You cannot specify a Color or a color name directly to bgcolor or fontcolor. The colorbg and colorfont options of FlameGraphs.FlameColors and FlameGraphs.StackFrameCategory are available.

:fcolor (default)

using FlameGraphs, Colors
fcolor = FlameColors(colorbg=colorant"steelblue", colorfont=colorant"lightyellow")

ProfileSVG.view(fcolor)
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407

:classic

ProfileSVG.view(bgcolor=:classic, fontcolor=:classic)
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407

:transparent and :currentcolor

The contextual, i.e. parent, background here has a pattern, and the font color depends on the theme (light or dark).

ProfileSVG.view(bgcolor=:transparent, fontcolor=:currentcolor)
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407

:bw

modcat(mod) = nothing
loccat(sf) = occursin("#", string(sf.func)) ? colorant"navy" : colorant"powderblue"

mysfc = StackFrameCategory(modcat, loccat, colorant"dimgray", colorant"red")

ProfileSVG.view(mysfc, fontcolor=:bw)
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407
Info

The decision whether to use black or white is based on the assumption that the frames are opaque. If the frameopacity option is set to a low value, the texts may be hard to read.

frameopacity option

The frameopacity option specifyies the opacity of frames in [0, 1]. This option affects only the background of the frame, not the texts or the viewport background.

The contextual background here has a pattern.

ProfileSVG.view(frameopacity=0.5, bgcolor=:transparent, fontcolor=:currentcolor)
Profile results in :-1 eval in boot.jl:331 profile_test in REPL[2]:3 randn in normal.jl:190 randn in normal.jl:184 randn! in normal.jl:173 setindex! in array.jl:826 randn in normal.jl:167 randn in normal.jl:40 rand in Random.jl:253 rand in generation.jl:119 rand in Random.jl:253 rand in RNGs.jl:370 reserve_1 in RNGs.jl:190 gen_rand in RNGs.jl:186 dsfmt_fill_array_close1_open2! in DSFMT.jl:86 mt_empty in RNGs.jl:180 getproperty in Base.jl:33 rand in RNGs.jl:371 rand_inbounds in RNGs.jl:366 rand_inbounds in RNGs.jl:362 mt_pop! in RNGs.jl:183 + in int.jl:53 randn in normal.jl:43 * in promotion.jl:312 * in float.jl:405 randn in normal.jl:45 randn_unlikely in normal.jl:58 exp in exp.jl:136 - in float.jl:403 profile_test in REPL[2]:5 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2029 inner_mapslices! in abstractarray.jl:2039 concatenate_setindex! in abstractarray.jl:2058 dotview in broadcast.jl:1138 maybeview in views.jl:124 profile_test in REPL[2]:7 mapslices##kw in abstractarray.jl:1972 #mapslices#115 in abstractarray.jl:2018 similar in abstractarray.jl:626 similar in array.jl:361 Array in boot.jl:415 Array in boot.jl:407