pprof_graphviz.bat

@echo off

SETLOCAL EnableDelayedExpansion

for /d %%d in (%USERPROFILE%\sdk\*) do (
    set sdk_dir=%%d
)

SETLOCAL DisableDelayedExpansion

rem 下面这行可能需要根据机器修改一下
set "go_dirs=%sdk_dir%\bin;%USERPROFILE%\go\bin"

set "graphviz_dir=%~dp0graphviz\bin"

set "PATH=%go_dirs%;%graphviz_dir%;%PATH%"

echo(
echo 插桩参考(常驻程序):
echo 1.修改 go.mod,添加依赖 github.com/gin-contrib/pprof v1.4.0
echo 2. main函数中添加
echo go func() {
echo     engine := gin.New()
echo     pprof.Register(engine)
echo     if err := engine.Run(":9090"); err != nil {
echo         panic(err)
echo     }
echo }()
echo(

echo(
echo 参考链接:https://zhuanlan.zhihu.com/p/396363069
echo(


echo(
echo 环境变量已配置,可以直接调用pprof图形化程序
echo(
echo 示例:go tool pprof -http=:6060 http://51.38.69.40:9090/debug/pprof/heap?seconds=100
echo 该命令会连接51.38.69.40的9090端口,采样100s,之后打开本地浏览器展示结果
echo(

cmd /k

 

posted @ 2024-01-26 17:56  易先讯  阅读(4)  评论(0编辑  收藏  举报