Skip to content

Commit

Permalink
additional processing stats
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Mar 4, 2025
1 parent ca0f67f commit 61d78b4
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/calculateBlockRate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/calculateBlockRate.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/polyfills/rpc-issues.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/polyfills/rpc-issues.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/processing-stats.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { Context } from './types';
export declare const processingStats: {
rpcCalls: number;
rpcCallTime: number;
rpcCallTypes: Map<string, number>;
};
export declare const printStats: (ctx: Context) => void;
2 changes: 2 additions & 0 deletions lib/processing-stats.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/processing-stats.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/calculateBlockRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export const calculateBlockRate = async (ctx: Context) => {
lastContextBlock = latestBlock.header
}

return blockRateResult
return blockRateResult || 1
}
2 changes: 2 additions & 0 deletions src/polyfills/rpc-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RpcClient.prototype.call = async function <T = any>(
// fs.writeFileSync(`rpcResponse${count}-in.json`, JSON.stringify({ method, params, options }, null, 2))
// fs.writeFileSync(`rpcResponse${count++}.json`, JSON.stringify(response, null, 2))
processingStats.rpcCallTime += Date.now() - time
processingStats.rpcCallTypes.set(method, (processingStats.rpcCallTypes.get(method) ?? 0) + 1)
return response
}
RpcClient.prototype.batchCall = async function <T = any>(batch: RpcCall[], options?: CallOptions<T>): Promise<T[]> {
Expand All @@ -35,6 +36,7 @@ RpcClient.prototype.batchCall = async function <T = any>(batch: RpcCall[], optio
// fs.writeFileSync(`rpcResponse$${count}-in.json`, JSON.stringify({ batch, options }, null, 2))
// fs.writeFileSync(`rpcResponse$${count++}.json`, JSON.stringify(response, null, 2))
processingStats.rpcCallTime += Date.now() - time
processingStats.rpcCallTypes.set(batch[0].method, (processingStats.rpcCallTypes.get(batch[0].method) ?? 0) + batch.length)
return response
}

Expand Down
2 changes: 2 additions & 0 deletions src/processing-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Context } from './types'
export const processingStats = {
rpcCalls: 0,
rpcCallTime: 0,
rpcCallTypes: new Map<string, number>(),
}

export const printStats = (ctx: Context) => {
Expand All @@ -20,4 +21,5 @@ export const printStats = (ctx: Context) => {
}
processingStats.rpcCalls = 0
processingStats.rpcCallTime = 0
processingStats.rpcCallTypes.clear()
}

0 comments on commit 61d78b4

Please sign in to comment.