hammer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hammer

type Hammer interface {
	// Run invokes a concurrency test, as described in /RATIONALE.md.
	//
	// * test is concurrently run in P goroutines, each looping N times.
	//   * name is unique within the hammer.
	// * onRunning is any function to run after all goroutines are running, but before test executes.
	//
	// On completion, return early if there's a failure like this:
	//	if t.Failed() {
	//		return
	//	}
	Run(test func(p, n int), onRunning func())
}

Hammer invokes a test concurrently in P goroutines N times per goroutine.

Here's an example:

P := 8               // max count of goroutines
N := 1000            // work per goroutine
if testing.Short() { // Adjust down if `-test.short`
	P = 4
	N = 100
}

hammer.NewHammer(t, P, N).Run(func(name string) {
	// Do test using name if something needs to be unique.
}, nil)

if t.Failed() {
	return // At least one test failed, so return now.
}

See /RATIONALE.md

func NewHammer

func NewHammer(t *testing.T, P, N int) Hammer

NewHammer returns a Hammer initialized to indicated count of goroutines (P) and iterations per goroutine (N). As discussed in /RATIONALE.md, optimize for Hammer.Run completing in .1 second on a modern laptop.

Jump to

Keyboard shortcuts

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