[Ethereum] how estimate average time for transactions to smart contract

block-intervaltimetimerstimestamptransactions

I have created a decentralized application on the Ethereum Blockchain network. This application receives data from different addresses on the blockchain network and saves this data in the blockchain network.
This data is sent as parameters, how do I calculate the response time for these transactions in milliseconds.
For example: Response time in milliseconds for reading data from the proposed smart contracts when the number of transactions = 1 and when the number of transactions is 100,200,300 and so on.

Best Answer

From what I understand, you are trying to estimate the time spent by calling a smart-contract (specifically a read call). In other words, how long does it take for a transaction to be processed by the blockchain?

Both read and write calls are sent as transactions, however, the latter requires mining and costs gas since it changes the state of the blockchain and requires consensus, while the former does not. The read call is just a database lookup that fetches the requested values from the blockchain, which is performed locally by the blockchain node that you are connected to.

(I am assuming that you already have established a connection to a blockchain node and that you are able to issue the calls)

For a read call, which does not require mining: You will have to record the time prior to calling the smart-contract (i.e. issuing the RPC call), let us call it t0, and record the time after the node responds to that call (i.e. when the requested value is returned), let us call it t1.

The time spent is simply, t1 - t0.

For a write call, which requires mining: t0 should be captured prior to sending the transaction and t1 should be captured when the confirmation message of that transaction is returned.

As above, the time spent is t1 - t0.

How to program it depends on what programming language you are using. For example, in Golang, you may use t0 = time.Now() to record the time at a specific point, and then use time.Now().Sub(t0) to get the duration (t1 - t0).

Related Topic