stressors

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package stressors implements resource stressors for CPU, Memory, I/O and network

Index

Constants

View Source
const DefaultSlice = 100 * time.Millisecond

DefaultSlice default CPU stress slice

Variables

This section is empty.

Functions

func CPUTime

func CPUTime() time.Duration

CPUTime returns the CPU time consumed by the current thread in nanoseconds

Types

type CPUDisruption

type CPUDisruption struct {
	Load int
	CPUs int
}

CPUDisruption defines a disruption that stress the CPU

type CPUStressor

type CPUStressor struct {
	Slice time.Duration
	Load  int
}

CPUStressor defines a stressor for CPU

func (*CPUStressor) Apply

func (s *CPUStressor) Apply(ctx context.Context) error

Apply stresses one CPU until the context is done This code is based on the cpu stress routing in stress-ng

type ResourceDisruption

type ResourceDisruption struct {
	CPUDisruption
}

ResourceDisruption defines a disruption that stress the CPU and Memory of a target

type ResourceStressOptions

type ResourceStressOptions struct {
	// Slice defines the interval of CPU stress. Default 100ms
	// Each slice is divided between busy and idle times to achieve a target load
	// Smaller slices should have smoother cpu consumption
	Slice time.Duration
}

ResourceStressOptions defines options that control the resource stressing

type ResourceStressor

type ResourceStressor struct {
	Options    ResourceStressOptions
	Disruption ResourceDisruption
}

ResourceStressor defines a resource stressor

func NewResourceStressor

func NewResourceStressor(disruption ResourceDisruption, options ResourceStressOptions) (*ResourceStressor, error)

NewResourceStressor creates a new ResourceStressor using the given options

func (*ResourceStressor) Apply

func (r *ResourceStressor) Apply(ctx context.Context, duration time.Duration) error

Apply applies the resource stress disruption for a given duration

Jump to

Keyboard shortcuts

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