package harness
import "gvisor.dev/gvisor/test/benchmarks/harness"
Package harness holds utility code for running benchmarks on Docker.
Index ¶
- func DebugLog(b *testing.B, msg string, args ...any)
- func DropCaches(machine Machine) error
- func Init() error
- func MakeMount(machine Machine, fsType FileSystemType, cu *cleanup.Cleanup) ([]mount.Mount, string, error)
- func SetFixedBenchmarks()
- func WaitUntilContainerServing(ctx context.Context, machine Machine, container *dockerutil.Container, port int) error
- type FileSystemType
- type Machine
Functions ¶
func DebugLog ¶
DebugLog prints debug messages if the debug flag is set.
func DropCaches ¶
DropCaches drops caches on the provided machine. Requires root.
func Init ¶
func Init() error
Init performs any harness initialization before runs.
func MakeMount ¶
func MakeMount(machine Machine, fsType FileSystemType, cu *cleanup.Cleanup) ([]mount.Mount, string, error)
MakeMount makes a mount and cleanup based on the requested type. Bind and volume mounts are backed by a temp directory made with mktemp. tmpfs mounts require no such backing and are just made. rootfs mounts do not make a mount, but instead return a target directory at root. It is up to the caller to call Clean on the passed *cleanup.Cleanup.
func SetFixedBenchmarks ¶
func SetFixedBenchmarks()
SetFixedBenchmarks causes all benchmarks to run once.
This must be set if they cannot scale with N. Note that this uses 1ns instead of 1x due to https://github.com/golang/go/issues/32051.
func WaitUntilContainerServing ¶
func WaitUntilContainerServing(ctx context.Context, machine Machine, container *dockerutil.Container, port int) error
WaitUntilContainerServing grabs a container from `machine` and waits for a server on the given container and port.
Types ¶
type FileSystemType ¶
type FileSystemType string
FileSystemType represents a type container mount.
const ( // BindFS indicates a bind mount should be created. BindFS FileSystemType = "bindfs" // TmpFS indicates a tmpfs mount should be created. TmpFS FileSystemType = "tmpfs" // RootFS indicates no mount should be created and the root mount should be used. RootFS FileSystemType = "rootfs" // FuseFS indicates a passthrough fuse server should be created. FuseFS FileSystemType = "fusefs" )
type Machine ¶
type Machine interface { // GetContainer gets a container from the machine. The container uses the // runtime under test and is profiled if requested by flags. GetContainer(ctx context.Context, log testutil.Logger) *dockerutil.Container // GetNativeContainer gets a native container from the machine. Native containers // use runc by default and are not profiled. GetNativeContainer(ctx context.Context, log testutil.Logger) *dockerutil.Container // RunCommand runs cmd on this machine. RunCommand(cmd string, args ...string) (string, error) // Returns IP Address for the machine. IPAddress() (net.IP, error) // CleanUp cleans up this machine. CleanUp() }
Machine describes a real machine for use in benchmarks.
func GetMachine ¶
GetMachine returns this run's implementation of machine.
Source Files ¶
harness.go machine.go util.go
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 4 hours ago –
Tools for package owners.