Go Benchmark

安装

1
go install github.com/cnlh/benchmark@latest

测试程序

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
package main

import "github.com/gin-gonic/gin"

func main() {
	r := gin.New()
	r.GET("/ping", func(ctx *gin.Context) {
		ctx.String(200, "pong")
	})
	r.Run(":8000")
}

使用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
> benchmark.exe -c 3000 -n 100000 http://127.0.0.1:8000/ping
Running 100000 test @ 127.0.0.1:8000 by 3000 connections
Request as following format:

GET /ping HTTP/1.1
Host: 127.0.0.1:8000

Requests/sec: 44579.28
Transfer/sec: 7.25MB
Error(s)    : 0
Percentage of the requests served within a certain time (ms)
    50%                         4
    65%                         6
    75%                         8
    80%                         8
    90%                         11
    95%                         14
    98%                         24
    99%                         128
   100%                         833