Framework of performance testing

Framework of performance testing

Build Status Go Report Card

fperf is a powerful and flexible framework which allows you to develop your own benchmark tools so much easy. You create the client and send requests, fperf do the concurrency and statistics, then give you a report about qps and latency. Any one can create powerful performance benchmark tools by fperf with only some knowledge about how to send a request.

Build fperf with the builtin clients

go install ./bin/fperf 

or use fperf-build

go install ./bin/fperf-build

fperf-build ./clients/*

Quick Start

If you can not wait to run fperf to see how it works, follow the quickstart here.

Customize client

You can build your own client based on fperf framework. A client in fact is a client that implement the fperf.Client or to say more precisely fperf.UnaryClient or fperf.StreamClient.

An unary client is a client to send requests. It works in request-reply model. For example, HTTP benchmark client is an unary client. See http client.

type Client interface {
        Dial(addr string) error
}
type UnaryClient interface {
        Client
        Request() error
}

A stream client is a client to send and receive data by stream or datagram. TCP and UDP nomarlly can be implemented as stream client. Google's grpc has a stream mode and can be used as a stream client. See grpc_testing

type StreamClient interface {
	Client
	CreateStream(ctx context.Context) (Stream, error)
}
type Stream interface {
	DoSend() error
	DoRecv() error
}

Three steps to create your own client

1.Create the "NewClient" function

package demo

import (
	"fmt"
	"github.com/fperf/fperf"
	"time"
)

type demoClient struct{}

func newDemoClient(flag *fperf.FlagSet) fperf.Client {
	return &demoClient{}
}

2.Implement the UnaryClient or StreamClient

func (c *demoClient) Dial(addr string) error {
	fmt.Println("Dial to", addr)
	return nil
}

func (c *demoClient) Request() error {
	time.Sleep(100 * time.Millisecond)
	return nil
}

3.Register to fperf

func init() {
	fperf.Register("demo", dewDemoClient, "This is a demo client discription")
}

Building custom clients

You client should be in the same workspace(same $GOPATH) with fperf.

Using fperf-build

fperf-build is a tool to build custom clients. It accepts a path of your package and create file autoimport.go which imports all your clients when build fperf, then cleanup the generated files after buiding.

Installing from source

go install ./bin/fperf-build

or installing from github

go get github.com/fperf/fperf/bin/fperf-build
fperf-build [packages]

packages can be go importpath(see go help importpath) or absolute path to your package

For example, build all clients alang with fperf(using relative importpath)

fperf-build ./clients/* 

Run benchmark

Options

Usage: ./fperf [options] <client>
options:
  -N int
        number of request per goroutine
  -async
        send and recv in seperate goroutines
  -burst int
        burst a number of request, use with -async=true
  -connection int
        number of connection (default 1)
  -cpu int
        set the GOMAXPROCS, use go default if 0
  -delay duration
        wait delay time before send the next request
  -goroutine int
        number of goroutines per stream (default 1)
  -recv
        perform recv action (default true)
  -send
        perform send action (default true)
  -server string
        address of the target server (default "127.0.0.1:8804")
  -stream int
        number of streams per connection (default 1)
  -tick duration
        interval between statistics (default 2s)
  -type string
        set the call type:unary, stream or auto. default is auto (default "auto")
clients:
 http   : HTTP performanch benchmark client
 mqtt-publish   : benchmark of mqtt publish
 redis  : redis performance benchmark

Draw live graph with grafana

TODO export data into influxdb and draw graph with grafana

Similar Resources

Full-featured test framework for Go! Assertions, mocking, input testing, output capturing, and much more! πŸ•

Full-featured test framework for Go! Assertions, mocking, input testing, output capturing, and much more! πŸ•

testza πŸ• Testza is like pizza for Go - you could life without it, but why should you? Get The Module | Documentation | Contributing | Code of Conduct

Dec 10, 2022

espresso - a framework for testing BigQuery queries

espresso - a framework for testing BigQuery queries Goals Componentization: compose complex queries from smaller, reusable components Test driven deve

Dec 7, 2022

Testy is a Go test running framework designed for Gametime's API testing needs.

template_library import "github.com/gametimesf/template_library" Overview Index Overview Package template_library is a template repository for buildin

Jun 21, 2022

Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio Fortio (Φορτίο) started as, and is, Istio's load testing tool and now graduated to be its own project. Fortio is also used by, among others, Me

Jan 2, 2023

:exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions

Package assert Package assert is a Basic Assertion library used along side native go testing Installation Use go get. go get github.com/go-playground/

Jan 6, 2023

Expressive end-to-end HTTP API testing made easy in Go

baloo Expressive and versatile end-to-end HTTP API testing made easy in Go (golang), built on top of gentleman HTTP client toolkit. Take a look to the

Dec 13, 2022

Simple Go snapshot testing

Simple Go snapshot testing

Incredibly simple Go snapshot testing: cupaloy takes a snapshot of your test output and compares it to a snapshot committed alongside your tests. If t

Jan 5, 2023

Clean database for testing, inspired by database_cleaner for Ruby

DbCleaner Clean database for testing, inspired by database_cleaner for Ruby. It uses flock syscall under the hood to make sure the test can runs in pa

Nov 17, 2022

Mutation testing for Go source code

go-mutesting go-mutesting is a framework for performing mutation testing on Go source code. Its main purpose is to find source code, which is not cove

Dec 28, 2022
A yaml data-driven testing format together with golang testing library

Specimen Yaml-based data-driven testing Specimen is a yaml data format for data-driven testing. This enforces separation between feature being tested

Nov 24, 2022
Ddosify - High-performance load testing tool
 Ddosify - High-performance load testing tool

Ddosify - High-performance load testing tool Features βœ”οΈ Protocol Agnostic - Currently supporting HTTP, HTTPS, HTTP/2. Other protocols are on the way.

Jan 5, 2023
Golang HTTP client testing framework

flute Golang HTTP client testing framework Presentation https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework Overview flute is the

Sep 27, 2022
API testing framework inspired by frisby-js
API testing framework inspired by frisby-js

frisby REST API testing framework inspired by frisby-js, written in Go Proposals I'm starting to work on frisby again with the following ideas: Read s

Sep 27, 2022
Minimal and Beautiful Go testing framework
Minimal and Beautiful Go testing framework

Goblin A Mocha like BDD testing framework written in Go that requires no additional dependencies. Requires no extensive documentation nor complicated

Dec 25, 2022
Testing framework for Go. Allows writing self-documenting tests/specifications, and executes them concurrently and safely isolated. [UNMAINTAINED]

GoSpec GoSpec is a BDD-style testing framework for the Go programming language. It allows writing self-documenting tests/specs, and executes them in p

Nov 28, 2022
πŸš€πŸŒ Orbital is a simple end-to-end testing framework for Go

Orbital is a test framework which enables a developer to write end to end tests just like one would writing unit tests. We do this by effectively copying the testing.T API and registering tests to be run periodically on a configured schedule.

Nov 18, 2022
An always-on framework that performs end-to-end functional network testing for reachability, latency, and packet loss

Arachne Arachne is a packet loss detection system and an underperforming path detection system. It provides fast and easy active end-to-end functional

Dec 31, 2022
BDD Testing Framework for Go
BDD Testing Framework for Go

Jump to the docs | δΈ­ζ–‡ζ–‡ζ‘£ to learn more. To start rolling your Ginkgo tests now keep reading! If you have a question, comment, bug report, feature reque

Jan 1, 2023
Professional lightweight testing mini-framework for Go.
Professional lightweight testing mini-framework for Go.

is Professional lightweight testing mini-framework for Go. Easy to write and read Beautifully simple API with everything you need: is.Equal, is.True,

Dec 28, 2022