Hi!
I have the following function:
function textview(
lines::Vector{T},
view::NTuple{4, Int};
active_highlight::String = _CSI * "30;43m",
active_match::Int = 0,
frozen_columns_at_beginning::Int = 0,
frozen_lines_at_beginning::Int = 0,
highlight::String = _CSI * "7m",
maximum_number_of_columns::Int = -1,
maximum_number_of_lines::Int = -1,
parse_decorations_before_view::Bool = false,
search_matches::Union{Nothing, Dict{Int, Vector{Tuple{Int, Int}}}} = nothing,
) where T<:AbstractString
I saw that the first call is taking 0.2s due to precompilation. I am trying to reduce it. I have already used SnoopCompile but I had minor gains, the precompilation is always happening when I first call the function. However, if I changed the signature to:
function textview(
lines::Vector{String},
view::NTuple{4, Int};
active_highlight::String = _CSI * "30;43m",
active_match::Int = 0,
frozen_columns_at_beginning::Int = 0,
frozen_lines_at_beginning::Int = 0,
highlight::String = _CSI * "7m",
maximum_number_of_columns::Int = -1,
maximum_number_of_lines::Int = -1,
parse_decorations_before_view::Bool = false,
search_matches::Union{Nothing, Dict{Int, Vector{Tuple{Int, Int}}}} = nothing,
)
Then the first call take less than 10ms, meaning that the precompilation happened during the package build process.
Question: how can I do this using the first signature? I really need that first approach because it must work with Vector{SubString{String}}
.
The information from SnoopCompile regarding inference time is:
julia> print_tree(tinf)
InferenceTimingNode: 0.192785/0.193579 on Core.Compiler.Timings.ROOT() with 1 direct children
ββ InferenceTimingNode: 0.000794/0.000794 on write(::IOBuffer, ::String, ::String, ::Vararg{String
}) with 0 direct children