I am using VS Code to run Go tests and CPU/memory profiling:
How to download/save a chart as an image?
I downloaded the results as *.gz
file:
I then used these commands to convert the *.gz
files into images. But I get the error:
dot -Tpng -Gdpi=1024 profile.pb.gz > profile.pb.gz.png Error: profile.pb.gz: syntax error in line 1 near '▼'
in addition:
dot -Tpng profile.pb.gz -o profile.pb.gz.png Error: profile.pb.gz: syntax error in line 1 near '▼'
profile.pb.gz contains (compressed) profiling data. Nothing to do with Graphviz.
Go includes the pprof tool, which can extract information from data in various formats, including PNG, GIF or SVG encoded images:
$ go tool pprof -png profile.pb.gz > foo.png $ file foo.png foo.png: PNG image data, 1164 x 1344, 8-bit/color RGB, non-interlaced
Please note that there is no need to gunzip the file.
See go tools pprof -h
for more options.
The above is the detailed content of How to get the CPU/memory profiling graph of a Go test as an image. For more information, please follow other related articles on the PHP Chinese website!