@@ -18,7 +18,8 @@ function updateCLI(
1818 totalSubscribedRef ,
1919 totalPublishersRef ,
2020 messageRateTs ,
21- rttValues
21+ rttValues ,
22+ rttArchive
2223) {
2324 return new Promise ( ( resolve ) => {
2425 let prevTime = Date . now ( ) ;
@@ -118,6 +119,7 @@ function writeFinalResults(
118119 totalSubscribed ,
119120 messageRateTs ,
120121 rttValues ,
122+ rttArchive ,
121123 perSecondStats
122124) {
123125 const duration = ( end - start ) / 1000 ;
@@ -128,44 +130,61 @@ function writeFinalResults(
128130 console . log ( `Total Duration: ${ duration . toFixed ( 6 ) } Seconds` ) ;
129131 console . log ( `Message Rate: ${ messageRate . toFixed ( 6 ) } msg/sec` ) ;
130132
133+ const result = {
134+ StartTime : Math . floor ( start / 1000 ) ,
135+ Duration : duration ,
136+ Mode : mode ,
137+ MessageRate : messageRate ,
138+ TotalMessages : totalMessages ,
139+ TotalSubscriptions : totalSubscribed ,
140+ ChannelMin : argv [ 'channel-minimum' ] ,
141+ ChannelMax : argv [ 'channel-maximum' ] ,
142+ SubscribersPerChannel : argv [ 'subscribers-per-channel' ] ,
143+ MessagesPerChannel : argv [ 'messages' ] ,
144+ MessageRateTs : messageRateTs ,
145+ OSSDistributedSlots : argv [ 'oss-cluster-api-distribute-subscribers' ] ,
146+ Addresses : [ `${ argv . host } :${ argv . port } ` ] ,
147+ PerSecondStats : perSecondStats
148+ } ;
149+
131150 if ( argv [ 'measure-rtt-latency' ] && ! mode . includes ( 'publish' ) ) {
132151 const histogram = hdr . build ( {
133152 lowestDiscernibleValue : 1 ,
134153 highestTrackableValue : 10_000_000 ,
135154 numberOfSignificantValueDigits : 3
136155 } ) ;
137156
138- rttValues . forEach ( ( rtt ) => {
157+ rttArchive . forEach ( ( rtt ) => {
139158 const val = Number ( rtt ) ;
140159 if ( val >= 0 ) histogram . recordValue ( val ) ;
141160 } ) ;
142161
143- console . log ( `Avg RTT ${ ( histogram . mean / 1000 ) . toFixed ( 3 ) } ms` ) ;
144- console . log ( `P50 RTT ${ ( histogram . getValueAtPercentile ( 50 ) / 1000 ) . toFixed ( 3 ) } ms` ) ;
145- console . log ( `P95 RTT ${ ( histogram . getValueAtPercentile ( 95 ) / 1000 ) . toFixed ( 3 ) } ms` ) ;
146- console . log ( `P99 RTT ${ ( histogram . getValueAtPercentile ( 99 ) / 1000 ) . toFixed ( 3 ) } ms` ) ;
147- console . log ( `P999 RTT ${ ( histogram . getValueAtPercentile ( 99.9 ) / 1000 ) . toFixed ( 3 ) } ms` ) ;
162+ const avgRtt = histogram . mean / 1000 ;
163+ const p50 = histogram . getValueAtPercentile ( 50 ) / 1000 ;
164+ const p95 = histogram . getValueAtPercentile ( 95 ) / 1000 ;
165+ const p99 = histogram . getValueAtPercentile ( 99 ) / 1000 ;
166+ const p999 = histogram . getValueAtPercentile ( 99.9 ) / 1000 ;
167+
168+ result . RTTSummary = {
169+ AvgMs : Number ( avgRtt . toFixed ( 3 ) ) ,
170+ P50Ms : Number ( p50 . toFixed ( 3 ) ) ,
171+ P95Ms : Number ( p95 . toFixed ( 3 ) ) ,
172+ P99Ms : Number ( p99 . toFixed ( 3 ) ) ,
173+ P999Ms : Number ( p999 . toFixed ( 3 ) ) ,
174+ totalCount : histogram . totalCount
175+ } ;
176+
177+ console . log ( `Avg RTT ${ avgRtt . toFixed ( 3 ) } ms` ) ;
178+ console . log ( `P50 RTT ${ p50 . toFixed ( 3 ) } ms` ) ;
179+ console . log ( `P95 RTT ${ p95 . toFixed ( 3 ) } ms` ) ;
180+ console . log ( `P99 RTT ${ p99 . toFixed ( 3 ) } ms` ) ;
181+ console . log ( `P999 RTT ${ p999 . toFixed ( 3 ) } ms` ) ;
182+ console . log ( `Total Messages tracked latency ${ histogram . totalCount } messages` ) ;
148183 }
149184
150185 console . log ( '#################################################' ) ;
151186
152187 if ( argv [ 'json-out-file' ] ) {
153- const result = {
154- StartTime : Math . floor ( start / 1000 ) ,
155- Duration : duration ,
156- Mode : mode ,
157- MessageRate : messageRate ,
158- TotalMessages : totalMessages ,
159- TotalSubscriptions : totalSubscribed ,
160- ChannelMin : argv [ 'channel-minimum' ] ,
161- ChannelMax : argv [ 'channel-maximum' ] ,
162- SubscribersPerChannel : argv [ 'subscribers-per-channel' ] ,
163- MessagesPerChannel : argv [ 'messages' ] ,
164- MessageRateTs : messageRateTs ,
165- OSSDistributedSlots : argv [ 'oss-cluster-api-distribute-subscribers' ] ,
166- Addresses : [ `${ argv . host } :${ argv . port } ` ] ,
167- PerSecondStats : perSecondStats
168- } ;
169188 fs . writeFileSync ( argv [ 'json-out-file' ] , JSON . stringify ( result , null , 2 ) ) ;
170189 console . log ( `Results written to ${ argv [ 'json-out-file' ] } ` ) ;
171190 }
0 commit comments