Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.8 KB

File metadata and controls

56 lines (39 loc) · 1.8 KB
description
Statistic routines etc

Other Routines

Getting the Full State Sync Statistic

The following function is used to evaluate syncing performance during the full state synchronizing

getStatFullSync(): SyncStat | undefined

{% hint style="info" %} The statistic within that function build during the full state sync only {% endhint %}

Returns

SyncStat object containing different performance indicators

Example

const stat = zkClient.getStatFullSync();
if (stat) {
   console.log(`Full state sync: ${stat.totalTime / 1000} sec`);
   console.log(`  avg speed:    ${stat.timePerTx.toFixed(1)} ms/tx`);
   console.log(`  total tx:     ${stat.txCount}`);
   console.log(`  cold-storage: ${stat.cdnTxCnt} txs`);
   console.log(`  memo items:   ${stat.decryptedLeafs}`);
}

Getting Average Sync Time

To retrieve average time spent on processing one transaction in the local state you can use the following method

getAverageTimePerTx(): number | undefined

{% hint style="info" %} The estimate can be inaccurate because the regular sync (opposite with the full one) fetches just few latest transactions so overhead can affect the average time {% endhint %}

Returns

average time per transaction in milliseconds or undefined if there is no statistic collected

Example

const avg = zkClient.getAverageTimePerTx();
console.log(`Average sync time: ${avg ?? -1} ms/tx`)
// output: Average sync time: 0.8 ms/tx