Documentation ¶
Overview ¶
Package cfg provides structured benchmark configuration.
Index ¶
- Constants
- func Write(w io.Writer, c Configuration) error
- type BoolValue
- type BytesValue
- type Configuration
- type Entry
- type Float64Value
- type FrequencyValue
- type Generator
- type GeneratorFunc
- type IntValue
- type Key
- type Labeled
- type PercentageValue
- type PropertyEntry
- type Provider
- type Providers
- type SectionEntry
- type StringValue
- type StringsValue
- type Tag
- type TimeValue
- type Validatable
- type Value
Constants ¶
const SectionSeparator = '-'
SectionSeparator separates section levels in key names.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BytesValue ¶
type BytesValue uint64
BytesValue represents bytes.
func (BytesValue) String ¶
func (b BytesValue) String() string
type Configuration ¶
type Configuration []Entry
Configuration is a nested key-value structure. It is a list of entries, where each entry is either a key-value property or a section containing a nested config.
func (Configuration) Validate ¶
func (c Configuration) Validate() error
Validate checks that all entries are valid.
type Entry ¶
type Entry interface { Labeled Validatable // contains filtered or unexported methods }
Entry is the base type for configuration entries. (Note this is a sealed interface, it may not be implemented outside this package.)
type Float64Value ¶
type Float64Value float64
Float64Value is a double-precision floating point.
func (Float64Value) String ¶
func (x Float64Value) String() string
type FrequencyValue ¶
type FrequencyValue float64
BytesValue represents bytes.
func (FrequencyValue) String ¶
func (f FrequencyValue) String() string
type Generator ¶
type Generator interface {
Configuration() (Configuration, error)
}
Generator generates Configuration.
type GeneratorFunc ¶
type GeneratorFunc func() (Configuration, error)
GeneratorFunc adapts a function to the Generator interface.
func (GeneratorFunc) Configuration ¶
func (g GeneratorFunc) Configuration() (Configuration, error)
Configuration calls g.
type Key ¶
type Key string
Key is an identifier for a config property or section.
func (Key) Validate ¶
Validate that the key conforms to the Go Benchmark Data Format.
A configuration line is a key-value pair of the form key: value where key begins with a lower case character (as defined by `unicode.IsLower`), contains no space characters (as defined by `unicode.IsSpace`) nor upper case characters (as defined by `unicode.IsUpper`), and one or more ASCII space or tab characters separate “key:” from “value.” Conventionally, multiword keys are written with the words separated by hyphens, as in cpu-speed.
type PercentageValue ¶
type PercentageValue float64
PercentageValue represents a percentage, therefore must be in the range 0 to 100.
func (PercentageValue) String ¶
func (p PercentageValue) String() string
func (PercentageValue) Validate ¶
func (p PercentageValue) Validate() error
Validate checks the p is between 0 and 100.
type PropertyEntry ¶
func KeyValue ¶
func KeyValue(k Key, v Value, tags ...Tag) PropertyEntry
KeyValue builds an undocumented property.
func PerfProperty ¶
func PerfProperty(k Key, doc string, v Value, tags ...Tag) PropertyEntry
PerfProperty builds a property tagged as performance critical.
func (PropertyEntry) Validate ¶
func (p PropertyEntry) Validate() error
Validate the property conforms to the Go Benchmark Data Format. This checks the key as well as the value, as described below.
There are no restrictions on value, except that it cannot contain a newline character. Value can be omitted entirely, in which case the colon must still be present, but need not be followed by a space.
In addition, if the property value is Validatable, its Validate method will be called.
type Provider ¶
Provider is a source of configuration.
func NewProvider ¶
NewProvider builds a Provider from a Generator.
func NewProviderFunc ¶
func NewProviderFunc(k Key, doc string, f func() (Configuration, error)) Provider
NewProviderFunc builds a Provider from a function.
type Providers ¶
type Providers []Provider
Providers is a list of providers.
func (Providers) Available ¶
Available returns true. Note that sub-providers will be checked for availability when Configuration() is called.
func (Providers) Configuration ¶
func (p Providers) Configuration() (Configuration, error)
Configuration gathers configuration from all providers.
func (Providers) FilterAvailable ¶
FilterAvailable returns the available sub-providers.
type SectionEntry ¶
type SectionEntry struct { Labeled Sub Configuration }
SectionEntry is a nested configuration.
func (SectionEntry) Available ¶
func (s SectionEntry) Available() bool
Available returns true (satisfies the Provider interface).
func (SectionEntry) Configuration ¶
func (s SectionEntry) Configuration() (Configuration, error)
Configuration satisfies the Provider interface.
func (SectionEntry) Validate ¶
func (s SectionEntry) Validate() error
Validate confirms the section key and sub-configuration are valid.
type StringValue ¶
type StringValue string
StringValue is a string constant.
func (StringValue) String ¶
func (s StringValue) String() string
type StringsValue ¶
type StringsValue []string
StringsValue is a list of strings.
func (StringsValue) String ¶
func (s StringsValue) String() string
type Tag ¶
type Tag string
Tag for a configuration property.
func ParseValueTags ¶
ParseValueTags parses tags from a configuration line value.
type Validatable ¶
type Validatable interface {
Validate() error
}
Validatable is something that can be validated.