common

package
v0.0.0-...-fddb751 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigHelp = `` /* 1469-byte string literal not displayed */
View Source
const Version = "v0.3.0"

Variables

View Source
var SupportedPlatforms = []Platform{
	{"linux", "amd64"},
}

Functions

func ConfigFileMarshalTOML

func ConfigFileMarshalTOML(c *ConfigFile) ([]byte, error)

Types

type BuildConfig

type BuildConfig struct {
	// BinDir is the path to the directory where all built binaries should be
	// placed.
	BinDir string

	// SrcDir is the path to the directory containing the benchmark's source
	// code, excluding benchmark code that is part of the Sweet repository.
	//
	// For instance, this directory would contain a pulled source repository.
	SrcDir string

	// BenchDir is the path to the benchmark's source directory in the Sweet
	// repository.
	BenchDir string

	// Short indicates whether or not to run a short version of the benchmarks
	// for testing. Guaranteed to be the same as GetConfig.Short and
	// RunConfig.Short.
	Short bool
}

type Config

type Config struct {
	Name        string                `toml:"name"`
	GoRoot      string                `toml:"goroot"`
	BuildEnv    ConfigEnv             `toml:"envbuild"`
	ExecEnv     ConfigEnv             `toml:"envexec"`
	PGOFiles    map[string]string     `toml:"pgofiles"`
	Diagnostics diagnostics.ConfigSet `toml:"diagnostics"`
}

func (*Config) Copy

func (c *Config) Copy() *Config

Copy returns a deep copy of Config.

func (*Config) GoTool

func (c *Config) GoTool() *Go

type ConfigEnv

type ConfigEnv struct {
	*Env
}

func (*ConfigEnv) UnmarshalTOML

func (c *ConfigEnv) UnmarshalTOML(data interface{}) error

type ConfigFile

type ConfigFile struct {
	Configs []*Config `toml:"config"`
}

type Env

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

func NewEnv

func NewEnv(vars ...string) (*Env, error)

func NewEnvFromEnviron

func NewEnvFromEnviron() *Env

func (*Env) Collapse

func (e *Env) Collapse() []string

func (*Env) Lookup

func (e *Env) Lookup(name string) (string, bool)

func (*Env) MustSet

func (e *Env) MustSet(vars ...string) *Env

func (*Env) Prefix

func (e *Env) Prefix(name, prefix string) *Env

func (*Env) Set

func (e *Env) Set(vars ...string) (*Env, error)

type GenConfig

type GenConfig struct {
	AssetsDir       string
	SourceAssetsDir string
	OutputDir       string
	GoTool          *Go
}

type Generator

type Generator interface {
	// Generate generates a new assets directory
	// from an old assets directory, given a configuration.
	Generate(*GenConfig) error
}

type GetConfig

type GetConfig struct {
	// SrcDir is the path to the directory that the harness should write
	// benchmark source into. This is then fed into the BuildConfig.
	//
	// The harness should not write benchmark source code from the Sweet
	// repository here; it need only collect source code it needs to fetch
	// from a remote source.
	SrcDir string

	// Short indicates whether or not to run a short version of the benchmarks
	// for testing. Guaranteed to be the same as BuildConfig.Short and
	// RunConfig.Short.
	Short bool
}

type Go

type Go struct {
	Tool       string
	Env        *Env
	PassOutput bool
}

func SystemGoTool

func SystemGoTool() (*Go, error)

func (*Go) BuildPackage

func (g *Go) BuildPackage(pkg, out string) error

func (*Go) BuildPath

func (g *Go) BuildPath(path, out string) error

func (*Go) Do

func (g *Go) Do(dir string, args ...string) error

func (*Go) GOROOT

func (g *Go) GOROOT() string

func (*Go) List

func (g *Go) List(args ...string) ([]byte, error)

type Harness

type Harness interface {
	// CheckPrerequisites checks benchmark-specific environment prerequisites
	// such as whether we're running as root or on a specific platform.
	//
	// Returns an error if any prerequisites are not met, nil otherwise.
	CheckPrerequisites() error

	// Get retrieves the source code for a benchmark and places it in srcDir.
	Get(g *GetConfig) error

	// Build builds a benchmark and places the binaries in binDir.
	Build(cfg *Config, b *BuildConfig) error

	// Run runs the given benchmark and writes Go `testing` formatted benchmark
	// output to `results`.
	Run(cfg *Config, r *RunConfig) error
}

type Platform

type Platform struct {
	GOOS, GOARCH string
}

func CurrentPlatform

func CurrentPlatform() Platform

func (Platform) BuildEnv

func (p Platform) BuildEnv(e *Env) *Env

func (Platform) String

func (p Platform) String() string

type RunConfig

type RunConfig struct {
	// BinDir is the path to the directory containing the benchmark
	// binaries.
	BinDir string

	// TmpDir is the path to a dedicated scratch directory.
	//
	// This directory is empty at the beginning of each run.
	TmpDir string

	// AssetsDir is the path to the directory containing runtime assets
	// for the benchmark.
	//
	// AssistsDir is reconstructed for each run, so files within are safe
	// to mutate.
	AssetsDir string

	// Args is a set of additional command-line arguments to pass to the
	// primary benchmark binary (e.g. -dump-cores).
	//
	// The purpose of this field is to plumb through flags that all
	// benchmarks support, such as flags for generating CPU profiles and
	// such.
	Args []string

	// Results is the file to which benchmark results should be appended
	// in the Go benchmark format.
	Results *os.File

	// Short indicates whether or not to run a short version of the benchmarks
	// for testing. Guaranteed to be the same as GetConfig.Short and
	// BuildConfig.Short.
	Short bool
}

Directories

Path Synopsis
Package profile supports working with pprof profiles.
Package profile supports working with pprof profiles.

Jump to

Keyboard shortcuts

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