-
Notifications
You must be signed in to change notification settings - Fork 20
/
meter.go
33 lines (26 loc) · 1.32 KB
/
meter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package overflow
import "github.com/onflow/cadence/common"
// a type representing a meter that contains information about the inner workings of an interaction, only available on local emulator
type OverflowMeter struct {
ComputationIntensities OverflowMeteredComputationIntensities `json:"computationIntensities"`
MemoryIntensities OverflowMeteredMemoryIntensities `json:"memoryIntensities"`
LedgerInteractionUsed int `json:"ledgerInteractionUsed"`
ComputationUsed int `json:"computationUsed"`
MemoryUsed int `json:"memoryUsed"`
}
// get the number of functions invocations
func (m OverflowMeter) FunctionInvocations() int {
return int(m.ComputationIntensities[common.ComputationKindFunctionInvocation])
}
// get the number of loops
func (m OverflowMeter) Loops() int {
return int(m.ComputationIntensities[common.ComputationKindLoop])
}
// get the number of statements
func (m OverflowMeter) Statements() int {
return int(m.ComputationIntensities[common.ComputationKindStatement])
}
// type collecting computatationIntensities
type OverflowMeteredComputationIntensities map[common.ComputationKind]uint
// type collecting memoryIntensities
type OverflowMeteredMemoryIntensities map[common.MemoryKind]uint