-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colorize weblist output #271
base: main
Are you sure you want to change the base?
Changes from 3 commits
b64b875
3c1cc88
f20b0fa
54536e0
2393a99
7f5dfe6
f8123b3
3e3a1c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,7 +215,7 @@ func PrintWebList(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFiles int) er | |
|
||
printFunctionHeader(w, ff.functionName, path, n.Flat, n.Cum, rpt) | ||
for _, fn := range fnodes { | ||
printFunctionSourceLine(w, fn, asm[fn.Info.Lineno], reader, rpt) | ||
printFunctionSourceLine(w, fn, asm[fn.Info.Lineno], reader, n.Cum, rpt) | ||
} | ||
printFunctionClosing(w) | ||
} | ||
|
@@ -347,20 +347,40 @@ func printFunctionHeader(w io.Writer, name, path string, flatSum, cumSum int64, | |
measurement.Percentage(cumSum, rpt.total)) | ||
} | ||
|
||
func calculatePercentile(partial, sum int64) string { | ||
percentile := partial * 100 / sum | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not percentile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change this. Misunderstood its meaning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aalexand I have now implemented percentile. I'm not sure if my code (in terms of style and correctness) is fine, thus I have pushed a first version without tests, to get it reviewed. I will add tests soon. I wonder if the percentiles functions should go into a different file or if they belong where they are. |
||
switch { | ||
case percentile > 80: | ||
return "percentile_80" | ||
case percentile > 60: | ||
return "percentile_60" | ||
case percentile > 40: | ||
return "percentile_40" | ||
case percentile > 20: | ||
return "percentile_20" | ||
case percentile > 10: | ||
return "percentile_10" | ||
} | ||
return "" | ||
} | ||
|
||
// printFunctionSourceLine prints a source line and the corresponding assembly. | ||
func printFunctionSourceLine(w io.Writer, fn *graph.Node, assembly []assemblyInstruction, reader *sourceReader, rpt *Report) { | ||
func printFunctionSourceLine(w io.Writer, fn *graph.Node, assembly []assemblyInstruction, reader *sourceReader, cumSum int64, rpt *Report) { | ||
percentile := calculatePercentile(fn.Cum, cumSum) | ||
if len(assembly) == 0 { | ||
fmt.Fprintf(w, | ||
"<span class=line> %6d</span> <span class=nop> %10s %10s %8s %s </span>\n", | ||
"<span class=line> %6d</span> <span class=\"nop %s\"> %10s %10s %8s %s </span>\n", | ||
fn.Info.Lineno, | ||
percentile, | ||
valueOrDot(fn.Flat, rpt), valueOrDot(fn.Cum, rpt), | ||
"", template.HTMLEscapeString(fn.Info.Name)) | ||
return | ||
} | ||
|
||
fmt.Fprintf(w, | ||
"<span class=line> %6d</span> <span class=deadsrc> %10s %10s %8s %s </span>", | ||
"<span class=line> %6d</span> <span class=\"deadsrc %s\"> %10s %10s %8s %s </span>", | ||
fn.Info.Lineno, | ||
percentile, | ||
valueOrDot(fn.Flat, rpt), valueOrDot(fn.Cum, rpt), | ||
"", template.HTMLEscapeString(fn.Info.Name)) | ||
srcIndent := indentation(fn.Info.Name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing space shouldn't be there.