diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 28da2e80e60e..43c316a9fcbf 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -17,10 +17,20 @@ package vm import ( + "time" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" "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 @@ -105,6 +115,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { // considered a revert-and-consume-all-gas operation except for // ErrExecutionReverted which means revert-and-keep-gas-left. 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 in.evm.depth++ defer func() { in.evm.depth-- }() diff --git a/geth-poa/docker-compose.yml b/geth-poa/docker-compose.yml index 33386cf70df8..d1c1e15c0df6 100644 --- a/geth-poa/docker-compose.yml +++ b/geth-poa/docker-compose.yml @@ -79,6 +79,7 @@ services: "eth*", "chain*", "clique*" + "vm*" ] } ] @@ -120,6 +121,7 @@ services: "eth*", "chain*", "clique*" + "vm*" ] } ] @@ -158,6 +160,7 @@ services: "eth*", "chain*", "clique*" + "vm*" ] } ]