That may be because you do not have the @truffle/contract package. I had the same problem. After running sudo npm install -g @truffle/contract the problem was solved. Check more at https://github.com/trufflesuite/truffle/tree/master/packages/contract.
You can measure the transaction time spent between creation until it appears on the blockchain.
Once you create the transaction you record the time with the hash in a database. When a transaction is mined you record the block timestamp.
There are other time you can measure also like the first time a transaction appears in the pending pool.
As said by Rob ...
My question is if there is a better way of measuring the time?
I suspect there is a conceptual disconnect. It's not a synchronous operation and the time is dependent on more factors than are accounted for here. Also, the rapid-fire transactions would probably lead to trouble in production if done this way.
Yes, you are measuring the ...