一、导入包

import _ "net/http/pprof"

二、启动监控routine

go func() {
http.ListenAndServe("0.0.0.0:18080", nil)
}() 三、访问web服务
例:分析CPU占用情况
go tool pprof http://localhost:18080/debug/pprof/profile
(pprof) top10
Total: 2525 samples
298 11.8% 11.8% 345 13.7% runtime.mapaccess1_fast64
268 10.6% 22.4% 2124 84.1% main.FindLoops
251 9.9% 32.4% 451 17.9% scanblock
178 7.0% 39.4% 351 13.9% hash_insert
131 5.2% 44.6% 158 6.3% sweepspan
119 4.7% 49.3% 350 13.9% main.DFS
96 3.8% 53.1% 98 3.9% flushptrbuf
95 3.8% 56.9% 95 3.8% runtime.aeshash64
95 3.8% 60.6% 101 4.0% runtime.settype_flush
88 3.5% 64.1% 988 39.1% runtime.mallocgc 四、参考
// pprof 命令
https://blog.golang.org/profiling-go-programs
// web 上几项监控指标
https://golang.org/pkg/net/http/pprof/

pprof进行golang程序性能分析的更多相关文章

  1. Golang程序性能分析

    前言 程序性能分析我相信是每个程序员都会遇到的问题,比如说一个程序的CPU为什么占用这么高?有没有优化的空间?又比如程序出现了内存泄漏如何排查等等.如果是C++程序会借助于Google pprof c ...

  2. Linux下的应用程序性能分析 总结

    Linux下的应用程序性能分析,根据内核程序和应用程序的不同,下文分两类进行描述. 我们侧重的是应用级别的程序,推荐google perf tool/kcachegrind组合 一.和内核有关的工具 ...

  3. Linux程序性能分析和火焰图

    Linux程序性能分析和火焰图 Linux程序的性能分析工具数量比较多,涉及到整个操作系统的方方面面,可能是开源的原因吧,相对于Windows来说丰富太多.其中应用分析性能方面Dtrace, Syst ...

  4. 八、jdk工具之JvisualVM、JvisualVM之二--Java程序性能分析工具Java VisualVM

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  5. [golang]7种 Go 程序性能分析方法

    视频信息 Seven ways to Profile Go Applicationsby Dave Cheneyat Golang UK Conf. 2016 视频:https://www.youtu ...

  6. Go1.5正式版程序性能分析小积累,实验环境windows64

    方法一: 内存分配器跟踪:GODEBUG=allocfreetrace=1 调度器追踪 调度器追踪能够提供对 goroutine 调度的动态行为的内视,而且同意调试负载平衡和可扩展性问题.要启用调度器 ...

  7. 使用Golang进行性能分析(Profiling)

    转自:http://www.cppblog.com/sunicdavy/archive/2015/04/11/210308.html 本文介绍游戏服务器的性能分析, web服务器性能分析不在本文分析范 ...

  8. python程序性能分析

    中文:http://www.cnblogs.com/zhouej/archive/2012/03/25/2379646.html 英文:https://www.huyng.com/posts/pyth ...

  9. JAVA程序性能分析及调优浅析

    1.性能分析本质 寻找系统的性能瓶颈(木桶理论/短板效应),并处理系统的性能瓶颈 2.性能分析主要指标负载.响应和服务器CPU\MEM等的使用率 3.性能分析主要工具 LoadRunner Visua ...

随机推荐

  1. div中文字上下居中

    <div class="title">Title</div> 1. 将div高度设成定值 2. 将line-height设成定值 3. 将text-alig ...

  2. vue 项目中命名方法

    命名 命名的方法通常有以下几类: 命名法说明 1).camel命名法,形如thisIsAnApple 2).pascal命名法,形如ThisIsAnApple 3).下划线命名法,形如this_is_ ...

  3. Docker私有仓库介绍

    安装环境 Centos 7.4 64位 安装Docker yum install docker 说明:docker新版本的安装方式和以前不一样,这里只是为了能运行Harbar, 不展开. 安装Dock ...

  4. oracle中查询当前系统时间用到的dual是什么?

    oracle我们查询当前系统时间的时候,经常用到dual,这个是什么东西呢? -- 查询系统时间 结果:2018/04/17 15:00:48 -- select sysdate from dual; ...

  5. decltype的参数是左值时,得到一个引用类型

    int* a = new int(10); decltype(*a) 得到的是引用类型:int&

  6. POJ 2243 Knight Moves(BFS)

    POJ 2243 Knight Moves A friend of you is doing research on the Traveling Knight Problem (TKP) where ...

  7. laravel自定义公共函数的引入

    原文地址:http://blog.csdn.net/u011415782/article/details/78925048 步骤指导 1. 创建 functions.php 在 app/Helpers ...

  8. learning at command AT+CSUB

    [Purpose] Learning how to get mobile module info [Eevironment] Shell terminal, base on gcom command ...

  9. java字符串根据空格截取并存进list,并在每个元素前后加上/

    public class List1 { public static void main(String[] args) { String s = "abc nnn ooo/xzsxc bs& ...

  10. @ResponseBody中文乱码解决方案

    java web项目,使用了springmvc4.0,用@ResponseBody返回中文字符串,乱码$$ 本以为很简单的问题,不过也找了一个小时. 网上有说这样配置的: <mvc:annota ...