bench

package
v0.0.13-0...-246b94f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Report

type Report struct {
	SendNum int // 已经发送的http 请求

	Number int // 发送总次数

	*http.Client
	// contains filtered or unexported fields
}

Report 是报表核心数据结构

func NewReport

func NewReport(ctx context.Context,
	c, n int,

	duration time.Duration,

	getRequest func() (*http.Request, error),

	client *http.Client) *Report

NewReport is a report initialization function

func (*Report) Cancel

func (r *Report) Cancel()

Cancel report logic

func (*Report) Init

func (r *Report) Init()

Init 初始化报表模块, 后台会起一个统计go程

func (*Report) Process

func (r *Report) Process(work chan struct{})

Process 负责构造压测http 链接和统计压测元数据

func (*Report) WaitAll

func (r *Report) WaitAll()

WaitAll 等待结束

type SubTasker

type SubTasker interface {
	Init()
	Process(chan struct{})
	Cancel()
	WaitAll()
}

SubTasker 是task模块的核心接口

type Task

type Task struct {
	Duration   time.Duration //压测时间
	Number     int           //压测次数
	Concurrent int           //并发数
	Rate       int           //压测频率
	// contains filtered or unexported fields
}

Task Task模块的核心数据结构

func (*Task) Run

func (t *Task) Run(sub SubTasker)

Run Task模块的入口函数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL