guonaihong / gout

gout to become the Swiss Army Knife of the http client @^^@---> gout 是http client领域的瑞士军刀,小巧,强大,犀利。具体用法可看文档,如使用迷惑或者API用得不爽都可提issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

您好想请问下如何获取压测结果通过接口传给其他服务

Rladmsrl opened this issue · comments

您好我想把压测结果传给另外一个接口,想问下怎么获取打印在控制台的结果 谢谢

使用GetReport接口就可以

package main

import (
        "fmt"
        "github.com/guonaihong/gout"
        "github.com/guonaihong/gout/bench"
)

const (
        benchNumber     = 30000
        benchConcurrent = 20
)

func main() {
        var r bench.Report

        err := gout.
                POST(":4444").                     //压测本地8080端口
                SetJSON(gout.H{"hello": "world"}). //设置请求body内容
                Filter().                          //打开过滤器
                Bench().                           //选择bench功能
                Concurrent(benchConcurrent).       //并发数
                Number(20).                        //压测次数
                GetReport(&r). //获取压测元数据
                Do()

        fmt.Printf("report:%v\n", r)

        if err != nil {
                fmt.Printf("%v\n", err)
        }
}

多谢!