benchmarking

package
v0.0.3-rc-1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 36 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Benchmarking ⏱️

Please check documentation here.

Documentation

Index

Constants

View Source
const RuntimeWasmBinary = "runtime-benchmarks.wasm"

Variables

View Source
var Config = initBenchmarkingConfig()

cmd flags and other options related to benchmarking

Functions

func NewLinear

func NewLinear(name string, min, max uint32) (*linear, error)

Used by benchmark tests to specify that a benchmarking variable is linear over some specified range, i.e. `NewLinear("a", 0, 1000)` means that the corresponding variable is allowed to range from `0` to `1000`, inclusive and generated weight file will accept arg named "a"

func RunDispatchCall

func RunDispatchCall(b *testing.B, outputPath string, testFn func(i *Instance), components ...*linear)

Executes a benchmark test. b is a go benchmark instance which must be provided by the calling test. outputPath is the path where weight file will be generated. testFn is a closure function that defines the test. It accepts a benchmarking instance param which is used to setup storage and run extrinsics. components is a registry for linear components variables which testFn may use.

func RunHook

func RunHook(b *testing.B,
	hookName string,
	setupFn func(storage *runtime.Storage),
	validateFn func(storage *runtime.Storage),
) benchmarkingtypes.BenchmarkResult

Types

type BlockBuilder

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

func NewBlockBuilder

func NewBlockBuilder(instance *Instance, inherentData []byte) BlockBuilder

func (*BlockBuilder) AddExtrinsic

func (bb *BlockBuilder) AddExtrinsic(extrinsic []byte) (bool, error)

AddExtrinsic adds an extrinsic to the simulated block. Returns true if the extrinsics application has reached the ExhaustsResource to the simulated block.

func (*BlockBuilder) ApplyInherentExtrinsics

func (bb *BlockBuilder) ApplyInherentExtrinsics() error

ApplyInherentExtrinsics converts the inherent data to extrinsics and adds them to the simulated block.

func (*BlockBuilder) FinishSimulation

func (bb *BlockBuilder) FinishSimulation() (gossamertypes.Block, error)

FinishSimulation finalizes the block and returns it. Restores the DB to the initial snapshot from StartSimulation

func (*BlockBuilder) StartSimulation

func (bb *BlockBuilder) StartSimulation(blockNumber uint) error

StartSimulation begins a block simulation by creating a snapshot of the DB and initialising the block.

type Instance

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

func (*Instance) BuildGenesisConfig

func (i *Instance) BuildGenesisConfig() error

func (*Instance) ExecuteExtrinsic

func (i *Instance) ExecuteExtrinsic(callName string, origin primitives.RawOrigin, args ...interface{}) error

Executes extrinsic with provided call name. Accepts optional param signer, which if provided is used to sign the extrinsic. Additionally the method appends the benchmark result to instance.benchmarkResults

func (*Instance) GetAccountInfo

func (i *Instance) GetAccountInfo(publicKey []byte) (gossamertypes.AccountInfo, error)

func (*Instance) InitializeBlock

func (i *Instance) InitializeBlock(blockNumber uint, timestamp uint64) error

func (*Instance) Metadata

func (i *Instance) Metadata() *ctypes.Metadata

Metadata returns the metadata of the current runtime instance.

func (*Instance) SetAccountInfo

func (i *Instance) SetAccountInfo(publicKey []byte, accountInfo gossamertypes.AccountInfo) error

Sets the specified account info for the specified public key

func (*Instance) Storage

func (i *Instance) Storage() *runtime.Storage

Returns Storage instance which can be used to modify the state during benchmark tests

type StatsResult

type StatsResult struct {
	Sum float64
	Min float64
	Max float64

	Mean   float64
	Median float64
	Stddev float64

	P99 float64
	P95 float64
	P75 float64
}

func NewStatsResult

func NewStatsResult(input []float64) (StatsResult, error)

func (StatsResult) String

func (s StatsResult) String() string

Jump to

Keyboard shortcuts

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