perfutil

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: 13 Imported by: 0

Documentation

Overview

Package perfutil provides utilities of storing performance data for UI tests.

Index

Constants

View Source
const DefaultRuns = 10

DefaultRuns provides the default number of iteration for a perftest conducts.

Variables

View Source
var UnstableModels = []string{
	"esche",
	"willow",
	"lava",
	"vilboz360",
	"woomax",
}

UnstableModels is the list of the models which appear to be not stable on the UI performance tests.

Functions

func CreateExpectations

func CreateExpectations(ctx context.Context, histnames ...string) map[string]float64

CreateExpectations creates the map of expected values for the given histogram names. It estimates the type of histogram (either of smoothness or latency) from the name.

func StoreLatency

func StoreLatency(ctx context.Context, pv *Values, hists []*metrics.Histogram) error

StoreLatency is a utility function to store input-latency metrics.

func StoreSmoothness

func StoreSmoothness(ctx context.Context, pv *Values, hists []*metrics.Histogram) error

StoreSmoothness is a utility function to store animation smoothness metrics.

Types

type Runner

type Runner struct {
	Runs       int
	RunTracing bool
	// contains filtered or unexported fields
}

Runner is an entity to manage multiple runs of the test scenario.

func NewRunner

func NewRunner(br *browser.Browser) *Runner

NewRunner creates a new instance of Runner.

func (*Runner) RunMultiple

func (r *Runner) RunMultiple(ctx context.Context, s *testing.State, name string, scenario ScenarioFunc, store StoreFunc) bool

RunMultiple runs scenario multiple times and store the data through store function. It invokes scenario+store 10 times, and then invokes scenario only with tracing enabled. If one of the runs fails, it quits immediately and reports an error. The name parameter is used for the prefix of subtest names for calling scenario/store function and the prefix for the trace data file. The name can be empty, in which case the runner uses default prefix values. Returns false when it has an error.

func (*Runner) Values

func (r *Runner) Values() *Values

Values returns the values in the runner.

type ScenarioFunc

type ScenarioFunc func(context.Context) ([]*metrics.Histogram, error)

ScenarioFunc is the function to conduct the test operation and returns the metric value.

func RunAndWaitAll

func RunAndWaitAll(tconn *chrome.TestConn, f func(ctx context.Context) error, names ...string) ScenarioFunc

RunAndWaitAll is a utility function to create ScenarioFunc which conducts f with metrics.RunAndWaitAll.

func RunAndWaitAny

func RunAndWaitAny(tconn *chrome.TestConn, f func(ctx context.Context) error, names ...string) ScenarioFunc

RunAndWaitAny is a utility function to create ScenarioFunc which conducts f with metrics.RunAndWaitAny.

type StoreFunc

type StoreFunc func(ctx context.Context, pv *Values, hists []*metrics.Histogram) error

StoreFunc is a function to be used for RunMultiple.

func StoreAll

func StoreAll(direction perf.Direction, unit, suffix string) StoreFunc

StoreAll is a function to store all histograms into values.

func StoreAllWithHeuristics

func StoreAllWithHeuristics(suffix string) StoreFunc

StoreAllWithHeuristics is a utility function to store all metrics. It determines the direction of perf (bigger is better or smaller is better) and unit through heuristics from the name of metrics.

type Values

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

Values keeps the reporting values for multiple runs.

func NewValues

func NewValues() *Values

NewValues creates a new Values instance.

func RunMultiple

func RunMultiple(ctx context.Context, s *testing.State, br *browser.Browser, scenario ScenarioFunc, store StoreFunc) *Values

RunMultiple is a utility to create a new runner, conduct runs multiple times, and returns the recorded values.

func (*Values) Append

func (v *Values) Append(metric perf.Metric, value float64)

Append adds a new data points to values.

func (*Values) Save

func (v *Values) Save(ctx context.Context, outdir string) error

Save is a shortcut of Values().Save(outdir). Helpful when the test does not have to combine with other data points.

func (*Values) Values

func (v *Values) Values(ctx context.Context) *perf.Values

Values creates a new perf.Values for its data points.

func (*Values) Verify

func (v *Values) Verify(ctx context.Context, expects map[string]float64) []error

Verify verifies the stored values with the numbers in expects and returns a list of misses of the expectations. If no problem, it will return empty.

Jump to

Keyboard shortcuts

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