16 lines
388 B
JavaScript
16 lines
388 B
JavaScript
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
|
|
}
|