Skip to content

Commit 8e53b1f

Browse files
StyledStrings fixes
1 parent 024866f commit 8e53b1f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

stdlib/Profile/src/Profile.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public clear,
3838
Allocs
3939

4040
import Base.StackTraces: lookup, UNKNOWN, show_spec_linfo, StackFrame
41+
import Base: AnnotatedString
4142
using StyledStrings: @styled_str
4243

4344
const nmeta = 4 # number of metadata fields per block (threadid, taskid, cpu_cycle_clock, thread_sleeping)
@@ -67,7 +68,7 @@ function _peek_report()
6768
iob = IOBuffer()
6869
ioc = IOContext(IOContext(iob, stderr), :displaysize=>displaysize(stderr))
6970
print(ioc, groupby = [:thread, :task])
70-
Base.print(stderr, String(take!(iob)))
71+
Base.print(stderr, read(seekstart(iob), AnnotatedString))
7172
end
7273
# This is a ref so that it can be overridden by other profile info consumers.
7374
const peek_report = Ref{Function}(_peek_report)
@@ -899,7 +900,7 @@ function indent(depth::Int)
899900
end
900901

901902
# mimics Stacktraces
902-
const PACKAGE_FIXEDCOLORS = Dict{String, Any}("@Base" => :light_black, "@Core" => :light_black)
903+
const PACKAGE_FIXEDCOLORS = Dict{String, Any}("@Base" => :gray, "@Core" => :gray)
903904

904905
function tree_format(frames::Vector{<:StackFrameTree}, level::Int, cols::Int, maxes, filenamemap::Dict{Symbol,Tuple{String,String}}, showpointer::Bool)
905906
nindent = min(cols>>1, level)
@@ -908,7 +909,7 @@ function tree_format(frames::Vector{<:StackFrameTree}, level::Int, cols::Int, ma
908909
ndigline = ndigits(maximum(frame.frame.line for frame in frames)) + 6
909910
ntext = max(30, cols - ndigoverhead - nindent - ndigcounts - ndigline - 6)
910911
widthfile = 2*ntext÷5 # min 12
911-
strs = Vector{Base.AnnotatedString{String}}(undef, length(frames))
912+
strs = Vector{AnnotatedString{String}}(undef, length(frames))
912913
showextra = false
913914
if level > nindent
914915
nextra = level - nindent
@@ -1118,7 +1119,7 @@ end
11181119
function print_tree(io::IO, bt::StackFrameTree{T}, cols::Int, fmt::ProfileFormat, is_subsection::Bool) where T
11191120
maxes = maxstats(bt)
11201121
filenamemap = Dict{Symbol,Tuple{String,String}}()
1121-
worklist = [(bt, 0, 0, "")]
1122+
worklist = [(bt, 0, 0, AnnotatedString(""))]
11221123
if !is_subsection
11231124
Base.print(io, "Overhead ╎ [+additional indent] Count File:Line; Function\n")
11241125
Base.print(io, "=========================================================\n")
@@ -1151,7 +1152,7 @@ function print_tree(io::IO, bt::StackFrameTree{T}, cols::Int, fmt::ProfileFormat
11511152
count = down.count
11521153
count < fmt.mincount && continue
11531154
count < noisefloor && continue
1154-
str = strs[i]
1155+
str = strs[i]::AnnotatedString
11551156
noisefloor_down = fmt.noisefloor > 0 ? floor(Int, fmt.noisefloor * sqrt(count)) : 0
11561157
pushfirst!(worklist, (down, level + 1, noisefloor_down, str))
11571158
end

0 commit comments

Comments
 (0)