Documentation
¶
Overview ¶
Package budget contains helpers for memory budget accounting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrExceeded = errors.New("memory budget exceeded")
ErrExceeded is returned when an operation would exceed the memory budget.
Functions ¶
func Concat ¶
Concat returns the memory cost of concatenating strings of lengths a and b. The result of a + b grows the largest of them by the size of the smallest.
func StringGrowth ¶
StringGrowth returns the memory cost of a string of length n produced from the input value in.
Strings are immutable, so the inputs of an operation already exist in memory: they are either part of the environment or were already accounted for. The cost is therefore the number of bytes by which the result exceeds its input. Scalar inputs (numbers, bools, etc.) produce strings of bounded size and cost nothing. Any other input (arrays, maps, structs) may reference the same string many times, so the whole result is charged.
Types ¶
This section is empty.