run

package
v0.0.0-...-6ef7557 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package run NOTES

Index

Constants

This section is empty.

Variables

View Source
var Concurrent int

Concurrent request concurrent number.

View Source
var SustainSeconds float64

SustainSeconds request sustain seconds.

View Source
var TotalRequest int64

TotalRequest is set,it has higher priority than SustainSecond

Functions

func Archive

func Archive(t string, m Metrics)

Archive metrics.

func GenReport

func GenReport(path string) error

GenReport gen html metrics report.

func SetBlue

func SetBlue(v interface{}) string

SetBlue set blue color.

func SetGreen

func SetGreen(v interface{}) string

SetGreen set green color.

func SetRed

func SetRed(v interface{}) string

SetRed set red color.

func SetYellow

func SetYellow(v interface{}) string

SetYellow set yellow color.

Types

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

Limiter request number limiter.

func NewStreamLimiter

func NewStreamLimiter(concurrent int) *Limiter

NewStreamLimiter new stream limiter.

func (*Limiter) Execute

func (sl *Limiter) Execute(ch chan<- *Status, f func() error)

Execute please use this func carefully. for instance, when you use this func in a for loop, please be sure that the f variable is concurrent secure.

func (*Limiter) IsEmpty

func (sl *Limiter) IsEmpty() bool

IsEmpty test limiter if empty.

func (*Limiter) Release

func (sl *Limiter) Release()

Release limiter release.

func (*Limiter) Require

func (sl *Limiter) Require()

Require limiter require.

type Metrics

type Metrics struct {
	// SustainSeconds 请求总时间
	SustainSeconds float64
	// Concurrent 并发数
	Concurrent int
	// QPS ...
	QPS float64
	// MaxDuration 单请求最大耗时
	MaxDuration float64
	// MinDuration 单请求最小耗时
	MinDuration float64
	// MedianDuration 平均时间
	MedianDuration float64
	// AverageDuration 请求平均耗时时间
	AverageDuration float64
	// Percent85Duration 处于85%位置的请求耗时
	Percent85Duration float64
	// Percent95Duration 处于95%位置的请求耗时
	Percent95Duration float64
	// TotalRequest 总请求数量
	TotalRequest int64
	// SucceedRequest 成功请求数量
	SucceedRequest int64
	// FailedRequest 失败请求数量
	FailedRequest int64
	// OnTheFlyRequest 波动请求数量
	OnTheFlyRequest int64
}

Metrics result.

func FireLoadTest

func FireLoadTest(f func() error) Metrics

FireLoadTest exec request and statistical data.

func (*Metrics) Format

func (m *Metrics) Format() string

Format NOTES

type Reporter

type Reporter struct {
	Data []metricsData
}

Reporter can count Metrics data and generate reports

func (*Reporter) Archive

func (a *Reporter) Archive(t string, m Metrics)

Archive archive bench data.

func (*Reporter) GenReport

func (a *Reporter) GenReport(path string) error

GenReport gen bench report.

type Statistic

type Statistic struct {
	// the total seconds of this statistic
	SustainSecond float64
	// the count of goroutines to run
	Concurrent int
	// total request that has been send.
	TotalRequest int64
	// success request number
	TotalSucceed int64
	// failed request number
	TotalFailed int64

	// in millisecond
	// only record success metrics
	TotalCostDuration float64
	Values            []float64
	// Request cost duration
	MinCostDuration float64
	MaxCostDuration float64
}

Statistic request control params.

func (*Statistic) CalculateMetrics

func (s *Statistic) CalculateMetrics() Metrics

CalculateMetrics calculate metrics.

func (*Statistic) CollectStatus

func (s *Statistic) CollectStatus(status *Status)

CollectStatus collect request status.

func (*Statistic) IncreaseFailed

func (s *Statistic) IncreaseFailed()

IncreaseFailed failed request.

func (*Statistic) IncreaseRequest

func (s *Statistic) IncreaseRequest()

IncreaseRequest total request.

func (*Statistic) IncreaseSuccess

func (s *Statistic) IncreaseSuccess()

IncreaseSuccess success request.

func (*Statistic) UpdateCostDuration

func (s *Statistic) UpdateCostDuration(t time.Duration)

UpdateCostDuration only update success request data

type Status

type Status struct {
	CostDuration time.Duration
	Error        error
}

Status request status.

Jump to

Keyboard shortcuts

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