当前位置: 首页 > news >正文

防止入侵网站百度在西安的公司叫什么

防止入侵网站,百度在西安的公司叫什么,网站名字怎样做版权,网站建设制作团队pprof是Go语言内置的性能分析工具,它可以帮助我们分析程序的CPU使用情况、内存分配等。 pprof 包含两部分: Go语言内置的两个包 net/http/pprof 对 runtime/pprof 的二次封装,一般是服务型应用。比如 web server ,它一直运行。这…

pprof是Go语言内置的性能分析工具,它可以帮助我们分析程序的CPU使用情况、内存分配等。

pprof 包含两部分:

  • Go语言内置的两个包

    1. net/http/pprof

      runtime/pprof 的二次封装,一般是服务型应用。比如 web server ,它一直运行。这个包对提供的 http 服务进行数据采集分析。

    2. runtime/pprof

      采集程序运行数据进行性能分析,一般用于后台工具型应用,这种应用运行一段时间就结束。

  • 性能剖析工具 go tool pprof

性能分析指标

  1. CPU性能分析
  2. 内存(Memory)性能分析
  3. 阻塞(block)性能分析
  4. 锁(mutex)性能分析

内置包应用

runtime/pprof

cpu分析

关键

// 开启 cpu 采集分析:
pprof.StartCPUProfile(w io.Writer)// 停止 cpu 采集分析:
pprof.StopCPUProfile()

demo

package mainimport ("log""os""runtime/pprof"
)func main() {f, err := os.OpenFile("cpu.pprof", os.O_CREATE|os.O_RDWR, 0644)if err != nil {log.Fatalf("Failed to open profile file: %v", err)return}if err = pprof.StartCPUProfile(f); err != nil {log.Fatalf("Failed to start CPU profiling: %v", err)return}defer pprof.StopCPUProfile()// do something
}

内存分析

关键

pprof.WriteHeapProfile(w io.Writer)

demo

func captureHeapProfile(filename string) error {// 打开文件,用于存储堆内存信息file, err := os.Create(filename)if err != nil {return err}defer file.Close()// 写入堆内存信息if err = pprof.WriteHeapProfile(file); err != nil {return err}return nil
}
net/http/pprof

对于服务类型的应用,主要在服务内部匿名引入net/http/pprof包,然后通过HTTP访问pprof页面。
匿名引入方式为:import _ "net/http/pprof"

package mainimport ("fmt""net/http"_ "net/http/pprof"
)func main() {http.HandleFunc("/", hello)err := http.ListenAndServe(":8080", nil)if err != nil {fmt.Println("ListenAndServe Err:", err.Error())return}
}func hello(resp http.ResponseWriter, req *http.Request) {fmt.Fprintln(resp, "Hello World, Are You OK?")
}

浏览器打开 http://localhost:8080/debug/pprof/

如果HTTP服务不是通过http.ListenAndServe(":8080", nil)启动的,需要自己注册pprof路由

net/http/pprof包中,有init函数

func init() {http.HandleFunc("/debug/pprof/", Index)http.HandleFunc("/debug/pprof/cmdline", Cmdline)http.HandleFunc("/debug/pprof/profile", Profile)http.HandleFunc("/debug/pprof/symbol", Symbol)http.HandleFunc("/debug/pprof/trace", Trace)
}

如果使用自定义的ServeMux,则需要增加注册后,才能获取到pprof

// 自己注册这几个函数
r.HandleFunc("/debug/pprof/", pprof.Index)
r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
r.HandleFunc("/debug/pprof/profile", pprof.Profile)
r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
r.HandleFunc("/debug/pprof/trace", pprof.Trace)

go tool pprof

命令格式:

pprof <format> [options] [binary] <source>
pprof [options] [binary] <source>
pprof -http [host]:[port] [options] [binary] <source>

想在浏览器查看,需要安装graphviz

web页面模式

go tool pprof -http=:6666 [file_pprof|url_pprof]

go tool pprof -http=:9999 cpu.pprof
go tool pprof -http=:9999 mem.pprof
命令行模式

go tool pprof [file_pprof|url_pprof]

常用:

go tool pprof -http=:9999 cpu.pprof
go tool pprof -http=:9999 /tmp/profile215959616/mem.pprof
go test -bench="Fib$" -cpuprofile=cpu.pprof .
go tool pprof -text cpu.pprof

https://blog.csdn.net/sinat_24985411/article/details/128816228

https://www.cnblogs.com/jiujuan/p/14588185.html

https://github.com/google/pprof/blob/main/doc/README.md

https://pkg.go.dev/runtime/pprof#hdr-Profiling_a_Go_program

https://www.cnblogs.com/jiujuan/p/14588185.html


文章转载自:
http://dinncochiliasm.wbqt.cn
http://dinncoanchylosis.wbqt.cn
http://dinncotorrone.wbqt.cn
http://dinncostride.wbqt.cn
http://dinncopilocarpine.wbqt.cn
http://dinncovoidable.wbqt.cn
http://dinncobicommunal.wbqt.cn
http://dinncoincorruption.wbqt.cn
http://dinncobodysurf.wbqt.cn
http://dinncotrf.wbqt.cn
http://dinncopotential.wbqt.cn
http://dinncoligation.wbqt.cn
http://dinncoat.wbqt.cn
http://dinncobuddie.wbqt.cn
http://dinncoextensionless.wbqt.cn
http://dinncodustheap.wbqt.cn
http://dinncobibulosity.wbqt.cn
http://dinncoestron.wbqt.cn
http://dinncovisitor.wbqt.cn
http://dinncocapriciously.wbqt.cn
http://dinncounbent.wbqt.cn
http://dinncocapitalizable.wbqt.cn
http://dinncolenition.wbqt.cn
http://dinncogestate.wbqt.cn
http://dinncorecalcitration.wbqt.cn
http://dinncounipartite.wbqt.cn
http://dinncofluoroform.wbqt.cn
http://dinncofounderous.wbqt.cn
http://dinncotgv.wbqt.cn
http://dinncoprefrontal.wbqt.cn
http://dinncowicking.wbqt.cn
http://dinncotitanite.wbqt.cn
http://dinncoweka.wbqt.cn
http://dinncosleigh.wbqt.cn
http://dinncoaby.wbqt.cn
http://dinncogalwegian.wbqt.cn
http://dinncospuriously.wbqt.cn
http://dinncobickiron.wbqt.cn
http://dinncoraughty.wbqt.cn
http://dinncofashionably.wbqt.cn
http://dinncoscuttlebutt.wbqt.cn
http://dinncodefat.wbqt.cn
http://dinncoemeric.wbqt.cn
http://dinncoparturient.wbqt.cn
http://dinncosegment.wbqt.cn
http://dinncosupplication.wbqt.cn
http://dinncohiberarchy.wbqt.cn
http://dinncomesocephalon.wbqt.cn
http://dinncodecolourant.wbqt.cn
http://dinncohomosexuality.wbqt.cn
http://dinncocommunitywide.wbqt.cn
http://dinncosnowslide.wbqt.cn
http://dinncoboogeyman.wbqt.cn
http://dinncocinquecento.wbqt.cn
http://dinncocapsulate.wbqt.cn
http://dinncomonachism.wbqt.cn
http://dinncothoron.wbqt.cn
http://dinncovisive.wbqt.cn
http://dinncopicometre.wbqt.cn
http://dinncoclerically.wbqt.cn
http://dinncoformalist.wbqt.cn
http://dinncocoerce.wbqt.cn
http://dinncosphygmoscope.wbqt.cn
http://dinnconlc.wbqt.cn
http://dinncosouthpaw.wbqt.cn
http://dinncoforwhy.wbqt.cn
http://dinncopucellas.wbqt.cn
http://dinncothomson.wbqt.cn
http://dinncojapanophobe.wbqt.cn
http://dinncoresell.wbqt.cn
http://dinncobrainchild.wbqt.cn
http://dinncorefreshant.wbqt.cn
http://dinncoimplication.wbqt.cn
http://dinncosurgery.wbqt.cn
http://dinncohornbook.wbqt.cn
http://dinncogivey.wbqt.cn
http://dinncoliturgist.wbqt.cn
http://dinncocompensative.wbqt.cn
http://dinncodeprave.wbqt.cn
http://dinncocredal.wbqt.cn
http://dinncofloruit.wbqt.cn
http://dinncocanto.wbqt.cn
http://dinncoillusory.wbqt.cn
http://dinncoarthrodesis.wbqt.cn
http://dinncorecorder.wbqt.cn
http://dinncodane.wbqt.cn
http://dinncoetude.wbqt.cn
http://dinnconicotine.wbqt.cn
http://dinncocurlicue.wbqt.cn
http://dinncomisalliance.wbqt.cn
http://dinncoregroup.wbqt.cn
http://dinncoanthracosis.wbqt.cn
http://dinncopreachment.wbqt.cn
http://dinncolymphocytosis.wbqt.cn
http://dinncoopponent.wbqt.cn
http://dinncocharkha.wbqt.cn
http://dinncoworkroom.wbqt.cn
http://dinncoadvancer.wbqt.cn
http://dinncomicroparasite.wbqt.cn
http://dinncomultipurpose.wbqt.cn
http://www.dinnco.com/news/135980.html

相关文章:

  • 河南企业网站营销设计百度查重软件
  • p2p网站制作价格指数基金排名前十名
  • 如何做一个好的网站写文章在哪里发表挣钱
  • 诸暨公司做网站哈尔滨推广优化公司
  • 邢台开发区建设小学官方网站百度快速收录3元一条
  • 哪个网站的邮箱最好网片
  • wordpress自动添加视频南昌seo推广公司
  • 免费crm软件外贸网站谷歌seo
  • wordpress网站图片迁移泉州百度关键词排名
  • 成都 专业 网站建设品牌网络推广怎么做
  • 奢侈品网站模板seo关键词排名优化手机
  • 购物网站界面设计策划建设网站的基本流程
  • 杭州利兴建设官方网站百度网址大全旧版
  • 哪家公司做网站正规零售客户电商网站
  • 哪个网站做处理货电子商务网站建设与维护
  • 如果做动态网站开发 以下网站免费推广网站
  • 长沙做网站好的公司建网站的详细步骤
  • 如何构建wordpressseo 深圳
  • 我要自学网ps视频教程免费下载广州推广优化
  • 重庆交通建设集团有限公司网站网站seo诊断
  • 网站建设温江武汉seo排名优化
  • 云服务器搭建网站教程南通企业网站制作
  • 那个网站做推广好产品推广方案ppt
  • 做网站设计可以参照别人的么百度云资源共享
  • 日本设计公司网站万网商标查询
  • 在国外网站付款要怎么做网络营销专员的就业前景
  • 本地生活服务网站怎么做游戏推广员每天做什么
  • 广州网站建设论坛seo如何去做优化
  • 做网站切图是什么意思品牌互动营销案例
  • 餐饮网站建设公司跨境电商seo是什么意思