ptesting

package
v0.4.170 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: ISC Imports: 10 Imported by: 2

Documentation

Overview

Package ptesting provides a platform identifier for Go benchmarks.

Index

Constants

View Source
const (
	OperationsPerSecond = "op/s"
	NanosecondsPerOp    = "ns/op"
	SecondsPerOp        = "sec/op"
)

Variables

This section is empty.

Functions

func BNString

func BNString(bN int) (s string)

BNString makes a b.N number readable

  • 1000000 → 1e6
  • 121293782 → 121,293,782

func Versions added in v0.4.66

func Versions() (keyValueLines string)

Versions returns printable key-value pairs for the Benchmark environment:

macOS:

goversion: go1.20.1
osversion: macOS 13.2.1
cpu: Apple M1 Max

Linux:

goversion: go1.20.1
osversion: Linux 5.19.0-32-generic
cpu: Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz

Usage:

func BenchmarkXxx(b *testing.B) {
  println(ptesting.Versions)
  …

Types

type SubBench

type SubBench struct {
	Name string
	D    time.Duration
	Runs []SubBenchRun
}

type SubBenchLogger

type SubBenchLogger struct {
	LastSubBench *SubBench
	T0           time.Time
	// contains filtered or unexported fields
}

func NewSubBenchLogger

func NewSubBenchLogger(b *testing.B) (sbl *SubBenchLogger)

NewSubBenchLogger returns an object to measure latency of each sub-benchmark b.N invocation

Usage:

func BenchmarkXxx(b *testing.B) {
  benchLogger := NewSubBenchLogger(b)
  defer benchLogger.Log()
  b.Run(…, func(b *testing.B) {
    defer benchLogger.Invo(b)

func (*SubBenchLogger) Invo

func (s *SubBenchLogger) Invo(b *testing.B)

func (*SubBenchLogger) Log

func (s *SubBenchLogger) Log()

type SubBenchRun

type SubBenchRun struct {
	BN      int
	Latency time.Duration
}

Jump to

Keyboard shortcuts

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