Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions cmd/flamegraph/flamegraph_renderers.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,32 @@ func renderFlameGraph(header string, tableValues table.TableValues, field string
out += "\n"
return
}

func callStackFrequencyTableHTMLRenderer(tableValues table.TableValues, targetName string) string {
out := `<style>

/* Custom page header */
.fgheader {
padding-bottom: 15px;
padding-right: 15px;
padding-left: 15px;
border-bottom: 1px solid #e5e5e5;
}

/* Make the masthead heading the same height as the navigation */
.fgheader h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
}

/* Customize container */
.fgcontainer {
max-width: 990px;
}
</style>
`
out += renderFlameGraph("Native", tableValues, "Native Stacks")
out += renderFlameGraph("Java", tableValues, "Java Stacks")
return out
}
29 changes: 0 additions & 29 deletions cmd/flamegraph/flamegraph_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,32 +282,3 @@ func mergeSystemFolded(perfFp string, perfDwarf string) (merged string, err erro
merged = mergedStacks.dumpFolded()
return
}

func callStackFrequencyTableHTMLRenderer(tableValues table.TableValues, targetName string) string {
out := `<style>

/* Custom page header */
.fgheader {
padding-bottom: 15px;
padding-right: 15px;
padding-left: 15px;
border-bottom: 1px solid #e5e5e5;
}

/* Make the masthead heading the same height as the navigation */
.fgheader h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
}

/* Customize container */
.fgcontainer {
max-width: 990px;
}
</style>
`
out += renderFlameGraph("Native", tableValues, "Native Stacks")
out += renderFlameGraph("Java", tableValues, "Java Stacks")
return out
}
19 changes: 16 additions & 3 deletions internal/report/render_html.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ func createHtmlReportMultiTarget(allTargetsTableValues [][]table.TableValues, ta
// loop through the targets that have values for this table
for targetIndex, targetTableValues := range tableValues {
targetName := tableTargets[targetIndex]
// if the table has rows and no custom renderer, print the table for the target normally
if targetTableValues.HasRows && getCustomHTMLMultiTargetRenderer(targetTableValues.Name) == nil {
// render the table for this target if it has a custom renderer
if shouldRenderTablePerTarget(targetTableValues) {
// print the table name only one time per table
if targetIndex == 0 {
fmt.Fprintf(&sb, "<h2 id=\"%[1]s\">%[1]s</h2>\n", html.EscapeString(targetTableValues.Name))
Expand All @@ -357,7 +357,7 @@ func createHtmlReportMultiTarget(allTargetsTableValues [][]table.TableValues, ta
} else {
sb.WriteString(DefaultHTMLTableRendererFunc(targetTableValues))
}
} else { // if the table has no rows or a custom renderer, add the table to the list to render as a multi-target table
} else { // if the table doesn't have a custom renderer, add it to the list to render as a multi-target table
oneTableValuesForAllTargets = append(oneTableValuesForAllTargets, targetTableValues)
}
}
Expand All @@ -384,6 +384,19 @@ func createHtmlReportMultiTarget(allTargetsTableValues [][]table.TableValues, ta
return
}

// shouldRenderTablePerTarget determines if a table should be rendered individually per target
// rather than as a combined multi-target comparison table.
// Renders per-target if:
// - The table has multiple rows (HasRows=true), OR
// - The table has a custom single-target renderer
//
// Unless a specific multi-target renderer exists for the table.
func shouldRenderTablePerTarget(tableValues table.TableValues) bool {
hasCustomRenderer := getCustomHTMLRenderer(tableValues.Name) != nil
hasMultiTargetRenderer := getCustomHTMLMultiTargetRenderer(tableValues.Name) != nil
return (tableValues.HasRows || hasCustomRenderer) && !hasMultiTargetRenderer
}

// findTableIndex
func findTableIndex(tableValues []table.TableValues, tableName string) int {
for i, tableValue := range tableValues {
Expand Down