16 lines
388 B
JavaScript
Raw Permalink Normal View History

2025-02-17 15:21:20 +07:00
export async function getTPS(agent) {
const perfSamples = await agent.connection.getRecentPerformanceSamples()
if (
!perfSamples.length ||
!perfSamples[0]?.numTransactions ||
!perfSamples[0]?.samplePeriodSecs
) {
throw new Error("No performance samples available")
}
const tps = perfSamples[0].numTransactions / perfSamples[0].samplePeriodSecs
return tps
}