qb

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 18 Imported by: 0

README

qb

CI

qb is a MySQL benchmarking tool using TPC-B(pgbench).

Usage

qb - MySQL benchmarking tool using TCP-B(same as pgbench).

  Flags:
       --version       Displays the program version string.
    -h --help          Displays help with available flag, subcommand, and positional value parameters.
    -d --dsn           Data Source Name, see https://github.com/go-sql-driver/mysql#examples.
    -i --initialize    Invokes initialization mode.
    -n --nagents       Number of agents. (default: 1)
    -t --time          Test run time (sec). Zero is infinity. (default: 60)
    -r --rate          Rate limit for each agent (qps). Zero is unlimited. (default: 0)
    -T --type          Transaction type (tpcb-like,simple-update,select-only). (default: tpcb-like)
    -s --scale         Scaling factor. (default: 1)
    -e --engine        Engine of the table to be created.
       --hinterval     Histogram interval, e.g. '100ms'. (default: 0)
       --only-print    Just print SQL without connecting to DB.
       --no-progress   Do not show progress.
       --ca-cert       Path to ca cert. Requires 'tls=custom' in DSN
       --client-cert   Path to client certificate. Requires 'tls=custom' in DSN.
       --client-key    Path to client key. Requires 'tls=custom' in DSN.
$ qb -d root@/ -i -s 10
dropping old database...
creating database...
creating tables...
generating data...
analyzing tables...

$ qb -d root@/ -n 10
01:00 | 10 agents / run 2907294 queries (4260 tps)

{
  "DSN": "root@/",
  "StartedAt": "2022-05-09T17:55:42.674904+09:00",
  "FinishedAt": "2022-05-09T17:56:42.677028+09:00",
  "ElapsedTime": 60,
  "NAgents": 10,
  "Rate": 0,
  "TransactionType": "tpcb-like",
  "Engine": "",
  "Token": "1665fb47-eb84-4ef4-9f12-f8ccc84b9248",
  "GOMAXPROCS": 16,
  "QueryCount": 2907294,
  "AvgTPS": 4404.898497183622,
  "MaxTPS": 5315.090909090909,
  "MinTPS": 0.2727272727272727,
  "MedianTPS": 4452.090909090909,
  "ExpectedTPS": 0,
  "Response": {
    "Time": {
      "Cumulative": "9m47.730783642s",
      "HMean": "150.102µs",
      "Avg": "202.157µs",
      "P50": "156.668µs",
      "P75": "208.138µs",
      "P95": "383.366µs",
      "P99": "669.418µs",
      "P999": "5.50043ms",
      "Long5p": "890.04µs",
      "Short5p": "80.223µs",
      "Max": "39.475841ms",
      "Min": "37.719µs",
      "Range": "39.438122ms",
      "StdDev": "393.538µs"
    },
    "Rate": {
      "Second": 4946.642375926489
    },
    "Samples": 2907294,
    "Count": 2907294,
    "Histogram": [
      {
        "37µs - 3.981ms": 2900756
      },
      {
        "3.981ms - 7.925ms": 5548
      },
      {
        "7.925ms - 11.869ms": 643
      },
      {
        "11.869ms - 15.812ms": 137
      },
      {
        "15.812ms - 19.756ms": 37
      },
      {
        "19.756ms - 23.7ms": 39
      },
      {
        "23.7ms - 27.644ms": 47
      },
      {
        "27.644ms - 31.588ms": 67
      },
      {
        "31.588ms - 35.532ms": 15
      },
      {
        "35.532ms - 39.475ms": 5
      }
    ]
  }
}

Documentation

Index

Constants

View Source
const (
	ProgressReportPeriod      = 1
	NBranches                 = 1
	NTellers                  = 10
	NAccounts                 = 100000
	InsertChunkSize           = 50000
	GeneratingDataConcurrency = 30
)
View Source
const (
	RecordPeriod = 1 * time.Second
)
View Source
const (
	ThrottleInterrupt = 1 * time.Millisecond
)

Variables

This section is empty.

Functions

func NewScript

func NewScript(name string, scale int) ([]string, error)

func ScriptNames

func ScriptNames() []string

Types

type Agent

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

type DB

type DB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Close() error
}

type MysqlConfig

type MysqlConfig struct {
	*mysql.Config
	OnlyPrint bool
}

type NullDB

type NullDB struct{}

func (*NullDB) Close

func (db *NullDB) Close() error

func (*NullDB) Exec

func (db *NullDB) Exec(query string, args ...interface{}) (sql.Result, error)

func (*NullDB) ExecContext

func (db *NullDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*NullDB) Query

func (db *NullDB) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*NullDB) QueryRow

func (db *NullDB) QueryRow(query string, args ...interface{}) *sql.Row

type Recorder

type Recorder struct {
	sync.Mutex
	RecorderOpts
	TaskOpts
	// contains filtered or unexported fields
}

func (*Recorder) Count

func (rec *Recorder) Count() int

func (*Recorder) Report

func (rec *Recorder) Report() (rr *RecorderReport)

type RecorderOpts

type RecorderOpts struct {
	DSN       string
	HInterval time.Duration
}

type RecorderReport

type RecorderReport struct {
	DSN         string
	StartedAt   time.Time
	FinishedAt  time.Time
	ElapsedTime time.Duration
	TaskOpts
	Token       string
	GOMAXPROCS  int
	QueryCount  int
	AvgTPS      float64
	MaxTPS      float64
	MinTPS      float64
	MedianTPS   float64
	ExpectedTPS int
	Response    *tachymeter.Metrics
}

type Task

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

func NewTask

func NewTask(taskOpts *TaskOpts, recOpts *RecorderOpts) (*Task, error)

func (*Task) Initialize

func (task *Task) Initialize() error

func (*Task) Prepare

func (task *Task) Prepare() error

func (*Task) Run

func (task *Task) Run() (*Recorder, error)

type TaskOpts

type TaskOpts struct {
	MysqlConfig     *MysqlConfig `json:"-"`
	NAgents         int
	Time            time.Duration `json:"-"`
	Rate            int
	TransactionType string
	Scale           int `json:"-"`
	Engine          string
	OnlyPrint       bool `json:"-"`
	NoProgress      bool `json:"-"`
}

Directories

Path Synopsis
cmd
qb

Jump to

Keyboard shortcuts

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