profiler

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package profiler supports capture various kind of system profiler data while running test.

Usage

p, err := profiler.Start(ctx, s, Profiler.Perf(nil), ...)
if err != nil {
	// Error handling...
}
defer func() {
	if err := p.End(); err != nil {
		// Error handling...
	}
}()

Index

Constants

View Source
const (

	// Used in perfStat to get CPU cycle count on all processes.
	PerfAllProcs = 0
)

Type of perf

Variables

This section is empty.

Functions

This section is empty.

Types

type PerfOpts

type PerfOpts struct {
	// contains filtered or unexported fields
}

PerfOpts represents options for running perf.

func PerfRecordOpts

func PerfRecordOpts() *PerfOpts

PerfRecordOpts creates a PerfOpts for running "perf record -e cycles -g" on the DUT.

func PerfSchedOpts

func PerfSchedOpts(out *PerfSchedOutput, procName string) *PerfOpts

PerfSchedOpts creates a PerfOpts for running "perf sched record" on the DUT.

func PerfStatOpts

func PerfStatOpts(out *PerfStatOutput, pid int) *PerfOpts

PerfStatOpts creates a PerfOpts for running "perf stat -a" on the DUT. out is a pointer to PerfStatOutput, which will hold CPU cycle count per second spent on pid process after End() is called on RunningProf. Set pid to PerfAllProcs to get cycle count for the whole system.

func PerfStatRecordOpts

func PerfStatRecordOpts() *PerfOpts

PerfStatRecordOpts creates a PerfOpts for running "perf stat record -a" on the DUT.

type PerfSchedOutput

type PerfSchedOutput struct {
	// Maximum latency from wake up to switch
	MaxLatencyMs float64
}

PerfSchedOutput holds output metrics of perf sched.

type PerfStatOutput

type PerfStatOutput struct {
	CyclesPerSecond float64
}

PerfStatOutput holds output of perf stat.

type Profiler

type Profiler func(ctx context.Context, outDir string) (instance, error)

Profiler is a function construct a profiler instance and start the profiler.

func Perf

func Perf(opts *PerfOpts) Profiler

Perf creates a Profiler instance that constructs the profiler. For opts parameter, nil is treated as the zero value of PerfOpts.

func Top

func Top(opts *TopOpts) Profiler

Top creates a Profiler instance that constructs and runs the profiler. For opts parameter, nil is treated as the zero value of TopOpts.

func VMStat

func VMStat(opts *VMStatOpts) Profiler

VMStat creates a Profiler instance that constructs and runs the profiler. For opts parameter, nil is treated as the zero value of VMStatOpts.

type RunningProf

type RunningProf []instance

RunningProf is the list of all running profilers.

func Start

func Start(ctx context.Context, outDir string, profs ...Profiler) (*RunningProf, error)

Start uses the set of input profiler constructors to start running each of it.

func (*RunningProf) End

func (p *RunningProf) End(ctx context.Context) error

End terminates all the profilers currently running.

type TopOpts

type TopOpts struct {
	// Interval indicates the duration between each poll.
	// The default value is 5 seconds.
	// Interval must be able to convert to a non-decimal in seconds.
	// For example, top can run 2 seconds but not 2.3 seconds.
	// 2.3 will be rounded to 2 for top interval.
	Interval time.Duration
}

TopOpts represents options for running top.

type VMStatOpts

type VMStatOpts struct {
	// Interval indicates the duration between each vmstat run.
	// The default value is 1 second.
	// Interval must be able to convert to a non-decimal in seconds.
	// For example, vmstat can run 2 seconds but not 2.3 seconds.
	// 2.3 will be rounded to 2 for vmstat interval.
	Interval time.Duration
}

VMStatOpts represents options for running vmstat.

Jump to

Keyboard shortcuts

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