I am currently trying to perform heavy load testing on a ERC20 token. My plan is to use truffle to test stuff like how long it would take for 500 transfer transactions to be deployed (on a private blockchain), maximum number of transactions per second and ideally some tests on scalability by including transactions from multiple nodes. Below is my code for running 500 transactions
const EnergyToken = artifacts.require("EnergyToken");
const assert = require('assert');
const truffleAssert = require('truffle-assertions');
const { performance } = require('perf_hooks');
const numberOfTransactions = 200;
contract("Energy Token Test3 ", async accounts => {
it("send $numberOfTransactions transactions from account 0 to account 1", async () => {
let contract = await EnergyToken.at("0x5BbD383bD43aC3896B86207eFe88cf0628ad06F0");
for (let i = 1; i < 1 + numberOfTransactions; i++) {
let t0 =performance.now();
contract.transfer.sendTransaction(accounts[1],1,{from: accounts[0]});
let t1 = performance.now();
console.log("Transaction " + i + " ***** From:" + accounts[0] + " ***** To: " + accounts[1] + "took " + (t1-t0) + " ms" );
}
});
The problem is that right now I am measuring the time it takes to submit those transactions, rather than how fast they are deployed. I tried using await before contract.transfer
but then transactions are processed 1 by 1 (1 tx per block) and it also takes an enormous amount of time. My question is if there is a better way of measuring the time?