gobench

package module
v0.0.0-...-db90efe Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 19 Imported by: 0

README

gobench

Write and plot your benchmark just in Go.

How to use

package main

import (
	"math/rand"
	"time"

	"github.com/kevwan/gobench"
)

func main() {
	b := gobench.NewBench()
	b.Run(10000, func() {
		n := rand.Intn(100)
		time.Sleep(time.Millisecond * time.Duration(n))
	})
}

After running a period, you can Ctrl+C to stop the benchmark and it will automatically open your browser and show the benchmark result like below:

image

Give a Star! ⭐

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bench

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

func NewBench

func NewBench() *Bench

func NewBenchWithConfig

func NewBenchWithConfig(cfg Config) *Bench

func (*Bench) Run

func (b *Bench) Run(qps int, fn func())

func (*Bench) RunErr

func (b *Bench) RunErr(qps int, fn func() error)

type Config

type Config struct {
	Host     string
	Port     int
	Title    string
	Duration time.Duration
}

type Task

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

Directories

Path Synopsis
examples
log

Jump to

Keyboard shortcuts

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