MCPcopy Create free account
hub / github.com/chain/txvm / measureProgram

Function measureProgram

protocol/txvm/asm/runlimit_test.go:1121–1140  ·  view source on GitHub ↗
(prog []byte, measuremem bool)

Source from the content-addressed store, hash-verified

1119}
1120
1121func measureProgram(prog []byte, measuremem bool) (int64, int64, int64) { // time, memory, runlimit
1122 memstats := new(runtime.MemStats)
1123 if measuremem {
1124 runtime.ReadMemStats(memstats)
1125 }
1126 start := time.Now()
1127 r := int64(1000000)
1128
1129 var runlimitLeft int64
1130 txvm.Validate(prog, 3, r, txvm.GetRunlimit(&runlimitLeft))
1131 r = r - runlimitLeft
1132 t := time.Now()
1133 elapsed := t.Sub(start)
1134 allocs := memstats.TotalAlloc
1135 if measuremem {
1136 runtime.ReadMemStats(memstats)
1137 }
1138 allocs = memstats.TotalAlloc - allocs
1139 return int64(elapsed), int64(allocs), r
1140}

Callers 1

TestInstructionsRunlimitFunction · 0.85

Calls 3

ValidateFunction · 0.92
GetRunlimitFunction · 0.92
SubMethod · 0.45

Tested by

no test coverage detected