Skip to content

Instantly share code, notes, and snippets.

@a26nine
Created November 4, 2022 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a26nine/f7a02f621095ccf16bb4d11146f85805 to your computer and use it in GitHub Desktop.
Save a26nine/f7a02f621095ccf16bb4d11146f85805 to your computer and use it in GitHub Desktop.
A simple script to test the response time of two node providers.
const solanaWeb3 = require('@solana/web3.js');
(async () => {
const SP = <YOUR_URL>;
const QN = <QN_ENDPOINT>;
const testCount = 7;
const establishConnection = async (rpcProvider) => {
const connection = new solanaWeb3.Connection(rpcProvider, 'confirmed');
return connection;
};
async function performTest(provider, conn, i) {
let startTime = Date.now();
await conn.getTransactionCount();
let endtTime = Date.now();
await console.log(`Round #[${i}] ${provider} : ${endtTime - startTime}ms`);
}
const connSP = await establishConnection(SP);
const connQN = await establishConnection(QN);
for (let i = 0; i < testCount; i++) {
performTest('StackPath', connSP, i);
performTest('QuickNode', connQN, i);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment