Skip to content

Commit

Permalink
chore: include heap profile into benchmark report and add notes for p…
Browse files Browse the repository at this point in the history
…rofiles (#4284)

include heap profile into benchmark report and add notes for profiles

Signed-off-by: shawnh2 <[email protected]>
  • Loading branch information
shawnh2 authored Sep 20, 2024
1 parent 1b56eda commit 91bea68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
17 changes: 15 additions & 2 deletions test/benchmark/suite/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func RenderReport(writer io.Writer, name, description string, titleLevel int, re
writeSection(writer, "Metrics", titleLevel+1, "")
renderMetricsTable(writer, reports)

writeSection(writer, "Profiles", titleLevel+1, "")
writeSection(writer, "Profiles", titleLevel+1, renderProfilesNote())
renderProfilesTable(writer, "Memory", "heap", titleLevel+2, reports)

return nil
Expand Down Expand Up @@ -149,14 +149,27 @@ func renderMetricsTable(writer io.Writer, reports []*BenchmarkReport) {
_ = table.Flush()
}

func renderProfilesNote() string {
return fmt.Sprintf(`The profiles at different scales are stored under %s directory in report, with name %s.
You can visualize them in a web page by running:
%s
Currently, the supported profile types are:
- heap
`, "`/profiles`", "`{ProfileType}.{TestCase}.pprof`", "```shell\ngo tool pprof -http=: path/to/your.pprof\n```")
}

func renderProfilesTable(writer io.Writer, target, key string, titleLevel int, reports []*BenchmarkReport) {
writeSection(writer, target, titleLevel, "")

for _, report := range reports {
// The image is not be rendered yet, so it is a placeholder for the path.
// The image will be rendered after the test has finished.
writeSection(writer, report.Name, titleLevel+1,
fmt.Sprintf("![%s-%s](%s.png)", key, report.Name, report.ProfilesPath[key]))
fmt.Sprintf("![%s-%s](%s.png)", key, report.Name,
strings.TrimSuffix(report.ProfilesPath[key], ".pprof")))
}
}

Expand Down
5 changes: 1 addition & 4 deletions tools/make/kube.mk
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ run-benchmark: install-benchmark-server ## Run benchmark tests
go test -v -tags benchmark -timeout $(BENCHMARK_TIMEOUT) ./test/benchmark --rps=$(BENCHMARK_RPS) --connections=$(BENCHMARK_CONNECTIONS) --duration=$(BENCHMARK_DURATION) --report-save-dir=$(BENCHMARK_REPORT_DIR)
# render benchmark profiles into image
dot -V
@for profile in $(wildcard test/benchmark/$(BENCHMARK_REPORT_DIR)/profiles/*.pprof); do \
$(call log, "Rendering profile image for: $${profile}"); \
go tool pprof -png $${profile} > $${profile}.png; \
done
find test/benchmark/$(BENCHMARK_REPORT_DIR)/profiles -name "*.pprof" -type f -exec sh -c 'go tool pprof -png "$$1" > "$${1%.pprof}.png"' _ {} \;

.PHONY: install-benchmark-server
install-benchmark-server: ## Install nighthawk server for benchmark test
Expand Down

0 comments on commit 91bea68

Please sign in to comment.