0

To analyze the execution time of different opcodes I've created the following modifications to the go-ethereum file instructions.go:

func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {

    // begin execution time tracking
    var startTime = time.Now().UnixNano();

    x, y := stack.pop(), stack.pop()
    stack.push(math.U256(x.Add(x, y)))

    evm.interpreter.intPool.put(y)

    // log ellapsed execution time
    fmt.Println("execute opAdd consume = ",(time.Now().UnixNano() - startTime))

    return nil, nil
}

I've attached to the client accordingly:

geth attach ipc:/Users/s.matthew.english/Library/Ethereum/testnet/geth.ipc

However, when I call a contract I've deployed to the ropsten testnet like so:

> var contractAbi = eth.contract([{"constant":false,"inputs":[{"name":"count","type":"uint256"}],"name":"increment","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getIteration","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"}]);

undefined

>  var myContract = contractAbi.at("0x8705C513da621a16fd1dEFc9dE8aE7CDEAD01Fb8");

undefined

> var getData = myContract.increment.getData(666);

undefined

> personal.unlockAccount(eth.coinbase, 'hunter2');

true

> web3.eth.sendTransaction({to:"0x8705C513da621a16fd1dEFc9dE8aE7CDEAD01Fb8", from:"0xd7a9a61a480d458a1181e0563b07f944df4489a6", data: getData});
"0x506535adb4bf088a862f7e6194bf23c73bd2ad2086830bc028be766323ffef1c"

> myContract.address

"0x8705C513da621a16fd1dEFc9dE8aE7CDEAD01Fb8"

> myContract.getIteration()

668

But I don't see those opcode execution times anywhere.

How can I make sure to log them to a place where I can actually observe and examine them?

More generally, what is the procedure to ensure that a function will write output to the console?

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.