gobench

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

README

Gobench

A distributed benchmark tool with Golang

Build Status

Why gobench

Targets: Supporting more than HTTP like MQTT, Websocket, graphQL. It can scale to support up to 1 million connection concurrently. It could support scriptable tool.

Workers

Supported workers: MQTT, NATs, HTTP

Please see the following section for creating a new type of worker.

Web API

Get histogram metric:

http://localhost:1234/api/metrics/55/histograms

Get histogram metric from a timestamp (ms)

http://localhost:1234/api/metrics/55/histograms?from=1586320159476&end=1586320169476

Tool gobench-reviewer

How to write a new worker

Creating a new type of worker for gobench is very simple. The worker has to have the following properties.

Expose the metrics

Exposes to gobench via gobench.Setup(groups) calling where groups is []metrics.Group{} structure.

For convience, one should call the metrics setup at the end of constructor like NewHttpClient on which calling gobench.Setup.

Gobench strickly force you to create the metrics hierarchy. Group name (Group.Name) must be unique globally. Also metric title (Metric.Title) must be unique globally.

Gobench is supporting 3 kinds of metric: counter, histogram, and gauge.

Notify the metric

Notify to gobench via gobench.Notify(metric name, value).

See workers/http for HTTP worker example.

Sponsor

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIdNotFound = errors.New("id not found")

Functions

func Notify

func Notify(title string, value int64) error

Notify saves the id with value into metrics which later save to database

func RandomByte

func RandomByte(length int) []byte

RandomByte returns a random byte array with length

func RandomString

func RandomString(length int) string

RandomString return a random string with length

func Setup

func Setup(groups []metrics.Group) error

Setup starts the gobench program by creating a collect entity and database to store units

func SleepLinear

func SleepLinear(rps float64) int64

SleepLinear put the program in sleep state for a certain time sleep time is a linear distribution with rps (rate per second) return the sleep time in micro seconds

func SleepPoisson

func SleepPoisson(rps float64) int64

SleepPoisson put the program in sleep state for a certain time sleep time is a poisson distribution with rps (rate per second) return the sleep time in micro seconds

Types

type Collect

type Collect struct {
	sync.Mutex

	DB *ent.Client
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *Collect

GetInstance returns the singleton instance of the benchmark

func NewBench

func NewBench() *Collect

NewBench returns the singleton instance of the benchmark

func (*Collect) Email

func (c *Collect) Email(config smtp.Config) *Collect

Email sets the smtp service configuration

func (*Collect) Finish

func (c *Collect) Finish() error

Finish closes the db connection and trigger services

func (*Collect) Name

func (c *Collect) Name(name string) *Collect

func (*Collect) Start

func (c *Collect) Start() error

Start function setup the db with benchCollect and begin to log metrics to db

Jump to

Keyboard shortcuts

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