import _ "net/http/pprof"

func main() {
go func() {
http.ListenAndServe("localhost:6060", nil)
}()
/** your logic code */
}

you can check the web status by this url :  http://localhost:6060/debug/pprof/

#Then use the pprof tool to look at the heap profile:

go tool pprof http://localhost:6060/debug/pprof/heap
Or to look at a 30-second CPU profile: go tool pprof http://localhost:6060/debug/pprof/profile
Or to look at the goroutine blocking profile: go tool pprof http://localhost:6060/debug/pprof/block

  

pprof info: https://github.com/g0hacker/go_command_tutorial/blob/master/0.12.md

go pprof的更多相关文章

  1. Golang pprof heap profile is empty

    Q: When you use `go tool pprof` get heap data, profile is empty. A: The default sampling rate is 1 s ...

  2. 使用go tool pprof分析内存泄漏、CPU消耗

    go中提供了pprof包来做代码的性能监控,在两个地方有包: net/http/pprof runtime/pprof 其实net/http/pprof中只是使用runtime/pprof包来进行封装 ...

  3. golang使用pprof检查goroutine泄露

    有一段时间,我们的推送服务socket占用非常不正常,我们自己统计的同一时候在线就10w的用户,可是占用的socket居然达到30w,然后查看goroutine的数量,发现已经60w+. 每一个用户占 ...

  4. Go的pprof使用

    go中有pprof包来做代码的性能监控,在两个地方有包: net/http/pprof runtime/pprof 其实net/http/pprof中只是使用runtime/pprof包来进行封装了一 ...

  5. Golang使用pprof和qcachegrind进行性能监控

    Golang为我们提供了非常方便的性能测试工具pprof,使用pprof可以非常方便地对Go程序的运行效率进行监测.本文讲述如何使用pprof对Go程序进行性能测试,并使用qcachegrind查看性 ...

  6. Go 程序的性能优化及 pprof 的使用

    Go 程序的性能优化及 pprof 的使用 程序的性能优化无非就是对程序占用资源的优化.对于服务器而言,最重要的两项资源莫过于 CPU 和内存.性能优化,就是在对于不影响程序数据处理能力的情况下,我们 ...

  7. 使用 pprof 和 Flame-Graph 调试 Golang 应用

    前言 最近用 Golang 实现了一个日志搜集上报程序(内部称 logger 项目),线上灰度测试过程发现 logger 占用 CPU 非常高(80% - 100%).而此项目之前就在线上使用,用于消 ...

  8. golang 使用pprof进行性能调优

    package main import "fmt" func lengthOfNonRepeatingSubStr(s string) int { lastOccurred := ...

  9. go笔记-pprof使用

    go tool pprof http://localhost:6060/debug/pprof/profile go tool pprof http://localhost:6060/debug/pp ...

随机推荐

  1. a^b的前n位数

    假设我们现在需要知道 ab  的后 n 位数或前 n 位数,简单直观的做法就是求出 ab  的值,然后在分别取前 n位或后 n位,不过在 a,b很大的情况下显然是无法存储的.所以,直接求是不可能的了. ...

  2. (原+译)LUA调用C函数

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5804924.html 原始网址: http://www.troubleshooters.com/cod ...

  3. 用GDAL/OGR去读shapefile

    一.读shapefile 1.首先,用Arcgis创建所要读的shp文件.打开ArcCatalog,右键NEW->Shapefile,名称Name:point ,要素类型(Feature Typ ...

  4. CSS3动画之透视

    若在x,y轴rotate90度,其实是线,不显示,按近大远小的透视关系可用 perspective:数值 开启透视: 默认以中间线为旋转基线,可以用transform-origin来设置旋转基线 在z ...

  5. commons-logging 和 log4j 之间的关系

    我们在做项目时,日志的记录是必不可少的一项任务,而我们通常是使用 apache 的 log4j 日志管理工具.然而,在项目中,我们经常会看到两个 jar 包:commons-logging.jar 和 ...

  6. [C++程序设计]对“&”和“*”运算符

    对“&”和“*”运算符再做些说明:(1) 如果已执行了“pointer_1=&a;”语句,请问&*pointer_1的含义是什么?“&”和“*”两个运算符的优先级别相同 ...

  7. tuple只有一个元素的时候,必须要加逗号

    In [1]: a = (1) In [2]: a Out[2]: 1 In [3]: a = (1,) In [4]: a Out[4]: (1,) 这是因为括号()既可以表示tuple,又可以表示 ...

  8. [TYVJ] P1006 ISBN

    ISBN 背景 Background NOIP2008年普及组第一题   描述 Description    每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字.1位识别码和3位 ...

  9. C# 集合性能 总结

    一.引言 本文主要记录的是C#各种集合操作的性能,下面的标记说明描述标记的时间,下面的表格对比各种集合各种操作的时间. 标记说明: O(1) 表示无论集合中有多少项,这个操作需要的时间都不变,例如,A ...

  10. 【剑指offer】面试题20:顺时针打印矩阵

    题目描述 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1     2  3   4 5    6   7   8 9   10 11 12 13 14 15 ...