Gin framework, the use of golang performance testing tool pprof

1. Import the response library file

import “github.com/gin-contrib/pprof”

r := gin.New()

pprof.Register(r, “debug/pprof”)

2. Send the request

Go-wrk (a Small Heavy Duty Benchmark Tool Wtitten in Go)

Git clone github.com/adjust/go-w…

go build

go-wrk [flags] url

go-wrk -c=400 -t=8 -n=100000 http://localhost:8080/index.html

Use the go – WRK send the response to a request at the same time, access to “http://127.0.0.1:8000/debug/pprof/profile”, to wait for download after 30 s to generate the profile file.

3. Analyze the profile

CD to the profile file directory run:

go tool pprof –http=”:8081″ profile

Serving web UI on http://localhost:8081

Through the generated picture frame size and time to find out the need to optimize the position.