Help us shape the future of Go! Take the 2026 Go Developer Survey

bench

package
v1.27.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package bench measures token performance with strictly bounded load.

Every run is capped by both wall-clock duration and an absolute operation budget per primitive, so a benchmark can never hammer a production HSM indefinitely. All key material is ephemeral (session objects only).

Index

Constants

View Source
const (
	DefaultDuration = 3 * time.Second
	MaxDuration     = 60 * time.Second
	DefaultMaxOps   = 5000
	HardMaxOps      = 1_000_000
	DefaultSessions = 1
	MaxSessions     = 32
)

Limits protecting tokens from unbounded load.

Variables

This section is empty.

Functions

This section is empty.

Types

type Measurement

type Measurement struct {
	Name      string        `json:"name"`
	Supported bool          `json:"supported"`
	Ops       int64         `json:"ops"`
	Elapsed   time.Duration `json:"elapsed_ns"`
	OpsPerSec float64       `json:"ops_per_sec"`
	Error     string        `json:"error,omitempty"`
}

Measurement is the result for one primitive.

type Options

type Options struct {
	Duration time.Duration `json:"duration_ns"`
	MaxOps   int           `json:"max_ops"`
	Sessions int           `json:"sessions"`
}

Options bounds a benchmark run.

func (Options) Normalize

func (o Options) Normalize() Options

Normalize applies defaults and clamps every option to its safety limit.

type Result

type Result struct {
	Options      Options       `json:"options"`
	Measurements []Measurement `json:"measurements"`
}

Result is a full benchmark run.

func Run

func Run(client *p11.Client, slotID uint, pin string, opts Options) (*Result, error)

Run executes all primitives sequentially, each bounded by opts.

Jump to

Keyboard shortcuts

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