benchops

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

Enabled is true when any benchmarking build tag is set. Used to gate all timing collection. The specific flags (OpsEnabled, StorageEnabled, NativeEnabled) gate what gets exported.

View Source
const NativeEnabled = false
View Source
const OpsEnabled = false
View Source
const RecordSize int = 14

the byte size of an exported record

View Source
const StorageEnabled = false

Variables

View Source
var Recording bool

Recording controls whether measurements are exported. Set to false during package loading to avoid contaminating benchmark data with init-phase store operations.

Functions

func BeginOpCode

func BeginOpCode(code byte)

BeginOpCode starts timing the first op in a run loop.

func Finish

func Finish()

func FinishNative

func FinishNative()

func FinishRun

func FinishRun()

func FinishStore

func FinishStore()

func Init

func Init(filepath string)

func InitMeasure

func InitMeasure()

func NativeCodeString

func NativeCodeString(nativeCode NativeOp) string

func OpAccumDur

func OpAccumDur(code byte) time.Duration

OpAccumDur returns the accumulated duration for an op code.

func OpCount

func OpCount(code byte) int64

OpCount returns the invocation count for an op code.

func ResetRun

func ResetRun()

ResetRun resets opcode measurements between machine runs.

func ResumeOpCode

func ResumeOpCode(code byte)

ResumeOpCode finalizes the current op's elapsed time and resumes a previous op without incrementing its count.

func StartNative

func StartNative(nativeCode NativeOp) byte

func StartStore

func StartStore(storeCode StoreOp) byte

StartStore suspends the current VM op timer and begins a store operation. Returns the old op code for ResumeOpCode.

func StopNative

func StopNative(nativeCode NativeOp, old byte)

func StopOpCode

func StopOpCode()

StopOpCode finalizes the current op. Used at OpHalt/return.

func StopStore

func StopStore(storeCode StoreOp, old byte, size int)

StopStore ends the store operation, records its duration and size, then resumes the previous VM op.

func StoreCodeString

func StoreCodeString(storeCode StoreOp) string

func SwitchOpCode

func SwitchOpCode(code byte) byte

SwitchOpCode finalizes the current op's elapsed time and starts timing a new op. Returns the old op code so the caller can pass it to ResumeOpCode when done.

Types

type CPUOp

type CPUOp byte

CPUOp represents a VM opcode for benchmarking. Values mirror gnolang.Op but are defined here to avoid circular imports.

const CPUOpInvalid CPUOp = 0x00

type Code

type Code [2]byte

func NativeCode

func NativeCode(nativeCode NativeOp) Code

func StoreCode

func StoreCode(storeCode StoreOp) Code

func VMOpCode

func VMOpCode(opCode CPUOp) Code

type NativeOp

type NativeOp byte

NativeOp represents a native operation for benchmarking.

const (
	NativeOpInvalid NativeOp = 0x00 // invalid

	NativePrint       NativeOp = 0x01 // print to console
	NativePrint_1     NativeOp = 0x02 // print to console
	NativePrint_1000  NativeOp = 0x03
	NativePrint_10000 NativeOp = 0x04 // print 1000 times to console

)

native code

func GetNativePrintCode

func GetNativePrintCode(size int) NativeOp

type StoreOp

type StoreOp byte

StoreOp represents a store operation for benchmarking.

const (
	StoreOpInvalid StoreOp = 0x00 // invalid

	// gno store
	StoreGetObject       StoreOp = 0x01 // get value and unmarshl to object from store
	StoreSetObject       StoreOp = 0x02 // marshal object and set value in store
	StoreDeleteObject    StoreOp = 0x03 // delete value from store
	StoreGetPackage      StoreOp = 0x04 // get package from store
	StoreSetPackage      StoreOp = 0x05 // get package from store
	StoreGetType         StoreOp = 0x06 // get type from store
	StoreSetType         StoreOp = 0x07 // set type in store
	StoreGetBlockNode    StoreOp = 0x08 // get block node from store
	StoreSetBlockNode    StoreOp = 0x09 // set block node in store
	StoreAddMemPackage   StoreOp = 0x0A // add mempackage to store
	StoreGetMemPackage   StoreOp = 0x0B // get mempackage from store
	StoreGetPackageRealm StoreOp = 0x0C // add mempackage to store
	StoreSetPackageRealm StoreOp = 0x0D // get mempackage from store

	AminoMarshal    StoreOp = 0x0E // marshal mem package and realm to binary
	AminoMarshalAny StoreOp = 0x0F // marshal gno object to binary
	AminoUnmarshal  StoreOp = 0x10 // unmarshl binary to gno object, package and realm

	// underlying store
	StoreGet StoreOp = 0x11 // Get binary value by key
	StoreSet StoreOp = 0x12 // Set binary value by key

	FinalizeTx StoreOp = 0x13 // finalize transaction

	// realm operations
	RealmDidUpdate  StoreOp = 0x14 // realm dirty tracking / escape analysis
	RealmFinalizeTx StoreOp = 0x15 // realm transaction finalization

)

store code

type Type

type Type byte
const (
	TypeOpCode Type = 0x01
	TypeStore  Type = 0x02
	TypeNative Type = 0x03
)

Jump to

Keyboard shortcuts

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