benchmark

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LevelInfo represents the name of the info-level
	LevelInfo = "info"

	// LevelError represents the name of the error-level
	LevelError = "error"

	// LevelDebug represents the name of the debug-level
	LevelDebug = "debug"

	// FieldTime represents the name of the time field
	FieldTime = "time"

	// FieldLevel represents the name of the level field
	FieldLevel = "level"

	// FieldError represents the name of the error field
	FieldError = "error"

	// FieldMessage represents the name of the message field
	FieldMessage = "message"

	// LogOperationInfo represents the name of an info-log operation
	LogOperationInfo = "info"

	// LogOperationInfoFmt represents the name of an info-log operation
	// involving formatting
	LogOperationInfoFmt = "info_fmt"

	// LogOperationInfoWithErrorStack represents the name of an info-log
	// operation involving a stack-traced error value
	LogOperationInfoWithErrorStack = "info_with_error_stack"

	// LogOperationInfoWith3 represents the name of an info-log operation
	// involving 3 newly appended fields
	LogOperationInfoWith3 = "info_with_3"

	// LogOperationInfoWith10 represents the name of an info-log operation
	// involving 10 newly appended fields
	LogOperationInfoWith10 = "info_with_10"

	// LogOperationError represents the name of an error-log operation
	LogOperationError = "error"

	// LogOperationInfoWith10Exist represents the name of an info-log operation
	// involving 10 previously appended fields
	LogOperationInfoWith10Exist = "info_with_10_exist"

	// TimeFormat defines the time logging format
	TimeFormat = "2006-01-02T15:04:05.999999999-07:00"
)

Variables

This section is empty.

Functions

func StartMemoryWatcher

func StartMemoryWatcher(
	ctx context.Context,
	interval time.Duration,
) (read chan MemStats)

StartMemoryWatcher starts a memory watcher goroutine which periodically writes memory statistics to the returned channel

Types

type Benchmark

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

Benchmark is a log benchmark

func New

func New(
	out io.ReadWriter,
	operation string,
	setup Setup,
) (*Benchmark, error)

New creates a new benchmark instance also initializing the logger

func (*Benchmark) Run

func (bench *Benchmark) Run(
	target uint64,
	concurrentWriters uint,
	stopped func() bool,
) Statistics

Run runs the benchmark

type Fields3

type Fields3 struct {
	Name1 string
	Name2 string
	Name3 string

	Value1 string
	Value2 int
	Value3 float64
}

Fields3 is a list of 3 fields and their according values

func NewFields3

func NewFields3() *Fields3

NewFields3 creates a new instance of a set of 3 fields

type Fields10

type Fields10 struct {
	Name1  string
	Name2  string
	Name3  string
	Name4  string
	Name5  string
	Name6  string
	Name7  string
	Name8  string
	Name9  string
	Name10 string

	Value1  string
	Value2  string
	Value3  string
	Value4  bool
	Value5  string
	Value6  int
	Value7  float64
	Value8  []string
	Value9  []int
	Value10 []float64
}

Fields10 is a list of 10 fields and their according values

func NewFields10

func NewFields10() *Fields10

NewFields10 creates a new instance of a set of 10 fields

type FnError

type FnError func(msg string)

FnError represents an error logging callback function

type FnInfo

type FnInfo func(msg string)

FnInfo represents an info logging callback function

type FnInfoFmt

type FnInfoFmt func(msg string, data int)

FnInfoFmt represents a formatted info logging callback function

type FnInfoWith3

type FnInfoWith3 func(msg string, fields *Fields3)

FnInfoWith3 represents an info logging callback function with 3 data fields attached

type FnInfoWith10

type FnInfoWith10 func(msg string, fields *Fields10)

FnInfoWith10 represents an info logging callback function with 10 data fields attached

type FnInfoWith10Exist

type FnInfoWith10Exist func(msg string)

FnInfoWith10Exist represents an info logging callback function with 10 previously attached data fields

type FnInfoWithErrorStack

type FnInfoWithErrorStack func(msg string, err error)

FnInfoWithErrorStack represents an info logging callback function with a stack-traced error attached

type MemStats

type MemStats struct {
	StatSamples    uint
	HeapAllocInc   uint64
	HeapObjectsInc uint64
	HeapSysInc     uint64
	MaxHeapAlloc   uint64
	MaxHeapObjects uint64
	MaxHeapSys     uint64
}

MemStats represents memory related statistics

type Setup

type Setup struct {
	Info               func(io.ReadWriter) (FnInfo, error)
	InfoFmt            func(io.ReadWriter) (FnInfoFmt, error)
	Error              func(io.ReadWriter) (FnError, error)
	InfoWithErrorStack func(io.ReadWriter) (FnInfoWithErrorStack, error)
	InfoWith3          func(io.ReadWriter) (FnInfoWith3, error)
	InfoWith10         func(io.ReadWriter) (FnInfoWith10, error)
	InfoWith10Exist    func(io.ReadWriter) (FnInfoWith10Exist, error)
}

Setup defines the callback functions for all benchmarked cases

type Statistics

type Statistics struct {
	TotalLogsWritten uint64
	TotalTime        time.Duration
}

Statistics are the statistics of the execution of a benchmark

Jump to

Keyboard shortcuts

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