美文网首页
51.Golang FlameGraph(火焰图)

51.Golang FlameGraph(火焰图)

作者: 一枼落知天下 | 来源:发表于2019-11-10 12:59 被阅读0次

1.安装组件

  1. 安装go-torch
    go get github.com/uber/go-torch
  2. 安装 FlameGraph
    cd $WORK_PATH && git clone https://gitee.com/mirrors/FlameGraph.git
    export PATH=$PATH:$WORK_PATH/FlameGraph
  3. 安装graphviz
    yum install graphviz(CentOS, Redhat)

2.代码修改

package main

import (
    "net/http"
    "net/http/pprof"
)

func main() {
    // 主函数中添加
    go func() {
        http.HandleFunc("/debug/pprof/block", pprof.Index)
        http.HandleFunc("/debug/pprof/goroutine", pprof.Index)
        http.HandleFunc("/debug/pprof/heap", pprof.Index)
        http.HandleFunc("/debug/pprof/threadcreate", pprof.Index)

        http.ListenAndServe("0.0.0.0:8888", nil)
    }()

    var finishWaiter chan int
    <-finishWaiter
}

3.查看结果

运行上述程序后,使用如下命令生成CPU火焰图:
go-torch -u http://localhost:8888/debug/pprof/ -p > profile-local.svg

相关文章

  • 51.Golang FlameGraph(火焰图)

    1.安装组件 安装go-torchgo get github.com/uber/go-torch 安装 Flame...

  • Golang FlameGraph(火焰图)

    1.安装组件 安装go-torchgo get github.com/uber/go-torch 安装 Flame...

  • C++:perf + Flame Graph火焰图生成

    1.安装FlameGraph 2.添加到环境变量 3.火焰图生成脚本

  • FlameGraph 火焰图快速指南(TiDB)

    快速开始 方法1:先生成 profile 文件,再使用工具解析 生成 profile 文件 生成 profile ...

  • Node.js性能优化之CPU篇

    perf + 火焰图 第一步 安装perf 第二步 clone FlameGraph 第三步 通过perf_bas...

  • erlang火焰图

    erlang火焰图 目录 火焰图相关什么是火焰图火焰图的意义 erlang火焰图如何绘制erlang火焰图erla...

  • 火焰图

    首先用 perf script 工具对 perf.data 进行解析 将解析出来的信息存下来, 供生成火焰图,首先...

  • 火焰图

    火焰图是性能分析的一大利器。可以抓取某个进程在一段时间内的函数调用栈的分布情况,从而知道哪些函数执行时间过长。 火...

  • Java 火焰图

    火焰图是进行性能分析的工具,可以通过Flame Graph获取指定程序的火焰图,目前IDEA也增添了火焰图功能,叫...

  • FlameGraph环境搭建

    写在前面:本文安装方法适用于Centos操作系统。 一、跟踪C函数cpu使用 参考:https://www.cnb...

网友评论

      本文标题:51.Golang FlameGraph(火焰图)

      本文链接:https://www.haomeiwen.com/subject/wkfabctx.html