internal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(w io.Writer, pkg build.Package, ctx Context) error

Build builds the specified package in order to produce the optimization output.

Types

type Context

type Context struct {
	Benchmarks    map[string]func(*testing.B)
	BuildOutput   string
	CompilerFlags []string
}

Context is an internal subset of lem.Context. Please refer to lem.Context for additional information.

type Int64Range

type Int64Range struct {
	Min int64
	Max int64
}

Int64Range is an inclusive range of int64 values.

func (Int64Range) Eq

func (i Int64Range) Eq(a int64) bool

Eq returns true when (Min==Max && a==Min) || (a>=Min && a<=Max).

func (Int64Range) String

func (i Int64Range) String() string

String returns the string version of this value.

type LineMatcher added in v0.1.1

type LineMatcher struct {
	// Regexp is matched against the build optimization output.
	Regexp *regexp.Regexp

	// Source is the line of source code for which this matcher was built.
	Source string
}

LineMatcher is a regular expression used to patch an expected expression from build optimization output for a line in a Go source file.

type TestCase

type TestCase struct {
	// ID maps to lem.<ID>.
	ID string

	// Name maps to lem.<ID>.name=<NAME>.
	// Please see the lem package documentation for more information.
	Name string

	// AllocOp maps to lem.<ID>.alloc=\d+(-\d+)? and is the expected number
	// of allocations per operation.
	AllocOp Int64Range

	// BytesOp maps to lem.<ID>.bytes=\d+(-\d+)? and is the expected number
	// of bytes per per operation.
	BytesOp Int64Range

	// Matches maps to lem.<ID>.m= and is a list of patterns that must appear
	// in the optimization output.
	Matches []LineMatcher

	// Natches maps to lem.<ID>.m!= and is a list of patterns that must appear
	// in the optimization output.
	Natches []LineMatcher
}

TestCase is a test case parsed from the lem comments in a source file.

func GetTestCases

func GetTestCases(files ...string) ([]TestCase, error)

GetTestCases parses the provided Go source files & returns a TestCase slice.

func (TestCase) Path

func (tc TestCase) Path() []string

Path returns the test case path from the provided ID and name. Please see the lem package documentation for more information.

type Tree

type Tree struct {
	TreeNode
	// contains filtered or unexported fields
}

func NewTree

func NewTree(testCases ...TestCase) Tree

NewTree returns a new Tree with the provided test cases.

func (*Tree) DeepEqual

func (tr *Tree) DeepEqual(b Tree) bool

DeepEqual returns true if the two trees are equal. Only exported fields are compared.

func (*Tree) Get

func (tr *Tree) Get(id string) *TestCase

func (*Tree) Insert

func (tr *Tree) Insert(testCase TestCase) *TestCase

func (Tree) Run

func (tr Tree) Run(t *testing.T, ctx Context)

Run the tests for this tree.

type TreeNode

type TreeNode struct {
	sync.Once
	Index map[string]int
	Steps []string
	Nodes []TreeNode
	Tests []TestCase
}

TreeNode organizes the TestCases in a tree structure.

Jump to

Keyboard shortcuts

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