Created
November 4, 2022 13:39
-
-
Save a26nine/f7a02f621095ccf16bb4d11146f85805 to your computer and use it in GitHub Desktop.
A simple script to test the response time of two node providers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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