@@ -6,7 +6,6 @@ import { mkdir, writeFile } from 'fs/promises';
66import path from 'path' ;
77
88import {
9- type CollectorType ,
109 type DistributionPattern ,
1110 WorkerClientManager ,
1211 testChainConfig ,
@@ -15,8 +14,6 @@ import {
1514const TEST_TIMEOUT_MS = 600_000 ; // 10 minutes
1615jest . setTimeout ( TEST_TIMEOUT_MS ) ;
1716
18- const COLLECTOR_TYPES : CollectorType [ ] = [ 'batch-requester' , 'send-batch-request' ] ;
19-
2017const PEERS_PER_RUN = 30 ;
2118const TIMEOUT_MS = 30_000 ;
2219
@@ -39,7 +36,6 @@ interface BenchmarkCase extends ScenarioBase {
3936interface BenchmarkResult {
4037 missingTxCount : number ;
4138 distribution : DistributionPattern ;
42- collector : CollectorType ;
4339 durationMs : number ;
4440 fetchedCount : number ;
4541 success : boolean ;
@@ -128,7 +124,7 @@ describe('ProposalTxCollector Benchmarks', () => {
128124 } ) ;
129125
130126 describe . each ( CASES ) ( '$name (missing=$missingTxCount)' , benchCase => {
131- it . each ( COLLECTOR_TYPES ) ( 'collector: %s ', async collectorType => {
127+ it ( 'runs batch tx requester benchmark ', async ( ) => {
132128 if ( ! workerManager ) {
133129 throw new Error ( 'Worker manager not initialized' ) ;
134130 }
@@ -137,15 +133,12 @@ describe('ProposalTxCollector Benchmarks', () => {
137133 const pinnedPeerIndex = distribution === 'pinned-only' ? benchCase . pinnedPeerIndex : undefined ;
138134 const seed = blockNumber * 1_000_000 ;
139135
140- logger . info (
141- `Case=${ benchCase . name } , missing=${ missingTxCount } , collector=${ collectorType } , peers=${ peers } , timeoutMs=${ timeoutMs } ` ,
142- ) ;
136+ logger . info ( `Case=${ benchCase . name } , missing=${ missingTxCount } , peers=${ peers } , timeoutMs=${ timeoutMs } ` ) ;
143137
144138 try {
145139 const result = await workerManager . runReqRespBenchmark ( {
146140 txCount : missingTxCount ,
147141 distribution,
148- collectorType,
149142 timeoutMs,
150143 pinnedPeerIndex,
151144 blockNumber,
@@ -155,22 +148,18 @@ describe('ProposalTxCollector Benchmarks', () => {
155148 results . push ( {
156149 missingTxCount,
157150 distribution,
158- collector : collectorType ,
159151 durationMs : result . durationMs ,
160152 fetchedCount : result . fetchedCount ,
161153 success : result . fetchedCount === missingTxCount ,
162154 } ) ;
163155
164- logger . info (
165- `${ collectorType } : fetched ${ result . fetchedCount } /${ missingTxCount } in ${ result . durationMs . toFixed ( 0 ) } ms` ,
166- ) ;
156+ logger . info ( `fetched ${ result . fetchedCount } /${ missingTxCount } in ${ result . durationMs . toFixed ( 0 ) } ms` ) ;
167157 } catch ( err : any ) {
168- logger . error ( `${ collectorType } failed: ${ err ?. message ?? String ( err ) } ` ) ;
158+ logger . error ( `Benchmark failed: ${ err ?. message ?? String ( err ) } ` ) ;
169159
170160 results . push ( {
171161 missingTxCount,
172162 distribution,
173- collector : collectorType ,
174163 durationMs : timeoutMs ,
175164 fetchedCount : 0 ,
176165 success : false ,
@@ -195,64 +184,23 @@ function toPrettyString(benchResults: BenchmarkResult[]): string {
195184 lines . push ( 'ProposalTxCollector Benchmark Results' ) ;
196185 lines . push ( '=' . repeat ( 80 ) ) ;
197186 lines . push ( '' ) ;
198- lines . push ( '| Collector | Distribution | Missing | Duration (ms) | Fetched | Success |' ) ;
199- lines . push ( '|---------------------|-------------- |---------|---------------|---------|---------|' ) ;
187+ lines . push ( '| Distribution | Missing | Duration (ms) | Fetched | Success |' ) ;
188+ lines . push ( '|--------------|---------|---------------|---------|---------|' ) ;
200189
201190 const sorted = [ ...benchResults ] . sort ( ( a , b ) => {
202191 if ( a . distribution !== b . distribution ) {
203192 return a . distribution . localeCompare ( b . distribution ) ;
204193 }
205- if ( a . missingTxCount !== b . missingTxCount ) {
206- return a . missingTxCount - b . missingTxCount ;
207- }
208- return a . collector . localeCompare ( b . collector ) ;
194+ return a . missingTxCount - b . missingTxCount ;
209195 } ) ;
210196
211197 for ( const r of sorted ) {
212198 lines . push (
213- `| ${ r . collector . padEnd ( 19 ) } | ${ r . distribution . padEnd ( 12 ) } | ${ String ( r . missingTxCount ) . padStart ( 7 ) } | ` +
199+ `| ${ r . distribution . padEnd ( 12 ) } | ${ String ( r . missingTxCount ) . padStart ( 7 ) } | ` +
214200 `${ r . durationMs . toFixed ( 0 ) . padStart ( 13 ) } | ${ String ( r . fetchedCount ) . padStart ( 7 ) } | ${ r . success ? ' Yes ' : ' No ' } |` ,
215201 ) ;
216202 }
217203
218- lines . push ( '' ) ;
219- lines . push ( '## Comparison Summary' ) ;
220- lines . push ( '' ) ;
221-
222- const keys = [ ...new Set ( sorted . map ( r => `${ r . distribution } :${ r . missingTxCount } ` ) ) ] ;
223-
224- for ( const key of keys ) {
225- const [ distRaw , missingRaw ] = key . split ( ':' ) ;
226- const dist = distRaw as DistributionPattern ;
227- const missing = Number ( missingRaw ) ;
228-
229- const batch = sorted . find (
230- r => r . distribution === dist && r . missingTxCount === missing && r . collector === 'batch-requester' ,
231- ) ;
232- const send = sorted . find (
233- r => r . distribution === dist && r . missingTxCount === missing && r . collector === 'send-batch-request' ,
234- ) ;
235-
236- if ( ! batch || ! send ) {
237- continue ;
238- }
239-
240- if ( ! batch . success || ! send . success ) {
241- lines . push (
242- `- ${ dist } (missing=${ missing } ): cannot compare reliably (success: batch=${ batch . success } , send=${ send . success } )` ,
243- ) ;
244- continue ;
245- }
246-
247- const faster = batch . durationMs <= send . durationMs ? 'BatchTxRequester' : 'SendBatchRequest' ;
248- const slower = faster === 'BatchTxRequester' ? 'SendBatchRequest' : 'BatchTxRequester' ;
249-
250- const delta = Math . abs ( send . durationMs - batch . durationMs ) ;
251- const pct = ( delta / Math . max ( batch . durationMs , send . durationMs ) ) * 100 ;
252-
253- lines . push ( `- ${ dist } (missing=${ missing } ): ${ faster } is ${ pct . toFixed ( 1 ) } % faster than ${ slower } ` ) ;
254- }
255-
256204 lines . push ( '' ) ;
257205 lines . push ( '=' . repeat ( 80 ) ) ;
258206 lines . push ( '' ) ;
@@ -264,7 +212,7 @@ function toBenchmarkJSON(benchResults: BenchmarkResult[], indent = 2): string {
264212 const metrics : JsonBenchmarkResult [ ] = [ ] ;
265213
266214 for ( const result of benchResults ) {
267- const baseName = `ProposalTxCollector/${ result . collector } / ${ result . distribution } /missing_${ result . missingTxCount } ` ;
215+ const baseName = `ProposalTxCollector/${ result . distribution } /missing_${ result . missingTxCount } ` ;
268216 metrics . push (
269217 {
270218 name : `${ baseName } /duration` ,
0 commit comments