🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] > [github](https://github.com/arl/statsviz) ## 概述 ### 流程 1. Import "github.com/arl/statsviz" 2. Register statsviz HTTP handlers 2. Start your program 3. Open your browser at http://host:port/debug/statsviz ![](https://github.com/arl/statsviz/raw/readme-docs/heap.png) ![](https://github.com/arl/statsviz/raw/readme-docs/mspan-mcache.png) ## 示例 ### hello world <details> <summary>main.go</summary> ``` package main import ( "log" "net/http" "github.com/arl/statsviz" ) func main() { // code mux := http.NewServeMux() statsviz.Register(mux) statsviz.RegisterDefault() go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() //code select {} } ``` </details> <br /> 执行 ``` > go run main.go ``` 浏览器访问 `http://127.0.0.1:6060/debug/statsviz/` ### gin <details> <summary>main.go</summary> ``` package main import ( "github.com/gin-gonic/gin" "github.com/arl/statsviz" example "github.com/arl/statsviz/_example" ) func main() { // Force the GC to work to make the plots "move". go example.Work() router := gin.New() router.GET("/debug/statsviz/*filepath", func(context *gin.Context) { if context.Param("filepath") == "/ws" { statsviz.Ws(context.Writer, context.Request) return } statsviz.IndexAtRoot("/debug/statsviz").ServeHTTP(context.Writer, context.Request) }) router.Run(":8080") } ``` </details> <br /> 执行 ``` > go run main.go ``` 浏览器访问 `http://127.0.0.1:8080/debug/statsviz/` ### 其他示例 > [github demo](https://github.com/arl/statsviz/tree/master/_example)