mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +00:00
feat: add metric to capture the execution time of the run method of the vm interpreter
This commit is contained in:
parent
99c407efbc
commit
86613b8fbb
2 changed files with 19 additions and 0 deletions
|
|
@ -17,10 +17,20 @@
|
||||||
package vm
|
package vm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// vmInterpreterRunExecutionTime is the name of a metric to capture the
|
||||||
|
// elapsed execution time (in nanoseconds) of the vm interpreter's Run
|
||||||
|
// method.
|
||||||
|
vmInterpreterRunExecutionTime = "vm/interpreter_run_execution_time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config are the configuration options for the Interpreter
|
// Config are the configuration options for the Interpreter
|
||||||
|
|
@ -105,6 +115,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
||||||
// considered a revert-and-consume-all-gas operation except for
|
// considered a revert-and-consume-all-gas operation except for
|
||||||
// ErrExecutionReverted which means revert-and-keep-gas-left.
|
// ErrExecutionReverted which means revert-and-keep-gas-left.
|
||||||
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
||||||
|
if metrics.Enabled {
|
||||||
|
defer func(start time.Time) {
|
||||||
|
metrics.GetOrRegisterTimer(vmInterpreterRunExecutionTime, nil).UpdateSince(start)
|
||||||
|
}(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
// Increment the call depth which is restricted to 1024
|
// Increment the call depth which is restricted to 1024
|
||||||
in.evm.depth++
|
in.evm.depth++
|
||||||
defer func() { in.evm.depth-- }()
|
defer func() { in.evm.depth-- }()
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ services:
|
||||||
"eth*",
|
"eth*",
|
||||||
"chain*",
|
"chain*",
|
||||||
"clique*"
|
"clique*"
|
||||||
|
"vm*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -120,6 +121,7 @@ services:
|
||||||
"eth*",
|
"eth*",
|
||||||
"chain*",
|
"chain*",
|
||||||
"clique*"
|
"clique*"
|
||||||
|
"vm*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -158,6 +160,7 @@ services:
|
||||||
"eth*",
|
"eth*",
|
||||||
"chain*",
|
"chain*",
|
||||||
"clique*"
|
"clique*"
|
||||||
|
"vm*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue