expgolang.org/x/exp/slog/benchmarks Index | Files

package benchmarks

import "golang.org/x/exp/slog/benchmarks"

Package benchmarks contains benchmarks for slog.

These benchmarks are loosely based on github.com/uber-go/zap/benchmarks. They have the following desirable properties:

As of Go 1.20, fetching the pc for a single nearby frame is slow. We hope to improve its speed before this package is released. Run the benchmarks with

-tags nopc

to remove this cost.

Index

Constants

const TestMessage = "Test logging, but use a somewhat realistic message length."
const WantText = "" /* 211 byte string literal not displayed */

Variables

var (
	TestTime     = time.Date(2022, time.May, 1, 0, 0, 0, 0, time.UTC)
	TestString   = "7e3b3b2aaeff56a7108fe11e154200dd/7819479873059528190"
	TestInt      = 32768
	TestDuration = 23 * time.Second
	TestError    = errors.New("fail")
)
var TestAttrs = []slog.Attr{
	slog.String("string", TestString),
	slog.Int("status", TestInt),
	slog.Duration("duration", TestDuration),
	slog.Time("time", TestTime),
	slog.Any("error", TestError),
}

Source Files

benchmarks.go handlers.go

Version
v0.0.0-20250218142911-aa4b98e5adaa (latest)
Published
Feb 18, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
2 days ago

Tools for package owners.