@@ -112,10 +112,15 @@ let finishTime = 0;
112112let totalSleepTime = 0 ;
113113let numStats = new Stats ( ) ;
114114const dateStats = {
115+ timestampFirst : new Stats ( ) ,
115116 timestamp : new Stats ( ) ,
117+ timestampDiff : new Stats ( ) ,
116118 timeDiff : new Stats ( ) ,
117119 timeDiffHistorical : new Stats ( ) ,
118- empty : 0
120+ empty : 0 ,
121+ numberOfRequestsWithLimitGreaterThanDefault : 0 ,
122+ numberOfRequestsWithNumberOfRecordsLessThanPageSize : 0 ,
123+ numberOfRequestsWithDataOlderThanAHalfYear : 0
119124}
120125
121126const deleteQuery = args . deleteQueryStats ;
@@ -206,6 +211,7 @@ async function replay(){
206211 requestUrl = dataArray [ i ] . req . split ( " " ) [ 1 ] ;
207212 }
208213 debugLogger . info ( `Sending ${ requestMethod } request to ${ requestUrl } at ${ now } ` ) ;
214+
209215 if ( args . stats ) {
210216 let statsUrl = new URL ( args . prefix + requestUrl ) ;
211217 if ( args . statsOnlyPath ) {
@@ -311,27 +317,81 @@ function parseResponse(response, method, url, sendTime, agent, originalStatus, t
311317 totalResponseTime += responseTime ;
312318 numStats . push ( responseTime ) ;
313319 if ( response . data ) {
314- if ( response . status . toString ( ) === "200" && args . dateStats ) {
315- let lastTimestamp ;
316- if ( url . includes ( "/getAddressTransactions" ) ) {
317- if ( response . data . length > 0 ) {
318- lastTimestamp = response . data [ response . data . length - 1 ] . timestamp ;
319- } else {
320- dateStats . empty += 1 ;
320+ if ( args . dateStats ) {
321+ let limit = 10 ;
322+ const urlObj = new URL ( args . prefix + url ) ;
323+ const pathname = urlObj . pathname ;
324+
325+ if ( pathname . includes ( '/getAddressTransactions' ) ||
326+ pathname . includes ( '/getTokenHistory' ) ||
327+ pathname . includes ( '/getAddressHistory' ) ) {
328+ const limitParam = urlObj . searchParams . get ( 'limit' ) ;
329+ if ( limitParam ) {
330+ limit = parseInt ( limitParam ) ;
321331 }
322- } else if ( url . includes ( "/getTokenHistory" ) || url . includes ( "/getAddressHistory" ) ) {
323- if ( response . data . operations . length > 0 ) {
324- lastTimestamp = response . data . operations [ response . data . operations . length - 1 ] . timestamp ;
325- }
326- } else if ( url . includes ( "/service/service.php?data=" ) ) {
327- if ( response . data . transfers . length > 0 ) {
328- lastTimestamp = response . data . transfers [ response . data . transfers . length - 1 ] . timestamp ;
332+ }
333+
334+ else if ( pathname . includes ( '/service/service.php' ) ) {
335+ const pageParam = urlObj . searchParams . get ( 'page' ) ;
336+
337+ if ( pageParam ) {
338+ const decodedPage = decodeURIComponent ( pageParam ) ;
339+ const pageSizeMatch = decodedPage . match ( / p a g e S i z e [ = % ] ( \d + ) / ) ;
340+ if ( pageSizeMatch ) {
341+ limit = parseInt ( pageSizeMatch [ 1 ] ) ;
342+ }
329343 }
330344 }
331- if ( lastTimestamp ) {
332- dateStats . timestamp . push ( lastTimestamp ) ;
333- dateStats . timeDiffHistorical . push ( timestamp / 1000 - lastTimestamp ) ;
334- dateStats . timeDiff . push ( ( + new Date ( ) / 1000 ) - lastTimestamp ) ;
345+ if ( limit > 10 ) {
346+ dateStats . numberOfRequestsWithLimitGreaterThanDefault ++ ;
347+ }
348+ if ( response . status . toString ( ) === "200" ) {
349+
350+ let lastTimestamp ;
351+ let firstTimestamp ;
352+ if ( url . includes ( "/getAddressTransactions" ) ) {
353+ if ( response . data . length > 0 ) {
354+ lastTimestamp = response . data [ response . data . length - 1 ] . timestamp ;
355+ firstTimestamp = response . data [ 0 ] . timestamp ;
356+ if ( response . data . length < limit ) {
357+ dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize ++ ;
358+ if ( lastTimestamp < ( timestamp / 1000 - 60 * 60 * 24 * 30 * 6 ) ) {
359+ dateStats . numberOfRequestsWithDataOlderThanAHalfYear ++ ;
360+ }
361+ }
362+ } else {
363+ dateStats . empty += 1 ;
364+ }
365+ } else if ( url . includes ( "/getTokenHistory" ) || url . includes ( "/getAddressHistory" ) ) {
366+ if ( response . data . operations . length > 0 ) {
367+ lastTimestamp = response . data . operations [ response . data . operations . length - 1 ] . timestamp ;
368+ firstTimestamp = response . data . operations [ 0 ] . timestamp ;
369+ if ( response . data . operations . length < limit ) {
370+ dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize ++ ;
371+ if ( lastTimestamp < ( timestamp / 1000 - 60 * 60 * 24 * 30 * 6 ) ) {
372+ dateStats . numberOfRequestsWithDataOlderThanAHalfYear ++ ;
373+ }
374+ }
375+ }
376+ } else if ( url . includes ( "/service/service.php?data=" ) ) {
377+ if ( response . data . transfers . length > 0 ) {
378+ lastTimestamp = response . data . transfers [ response . data . transfers . length - 1 ] . timestamp ;
379+ firstTimestamp = response . data . transfers [ 0 ] . timestamp ;
380+ if ( response . data . transfers . length < limit ) {
381+ dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize ++ ;
382+ if ( lastTimestamp < ( timestamp / 1000 - 60 * 60 * 24 * 30 * 6 ) ) {
383+ dateStats . numberOfRequestsWithDataOlderThanAHalfYear ++ ;
384+ }
385+ }
386+ }
387+ }
388+ if ( firstTimestamp ) {
389+ dateStats . timestamp . push ( lastTimestamp ) ;
390+ dateStats . timestampFirst . push ( firstTimestamp ) ;
391+ dateStats . timestampDiff . push ( firstTimestamp - lastTimestamp ) ;
392+ dateStats . timeDiffHistorical . push ( timestamp / 1000 - lastTimestamp ) ;
393+ dateStats . timeDiff . push ( ( + new Date ( ) / 1000 ) - lastTimestamp ) ;
394+ }
335395 }
336396 }
337397 if ( response . data . debug ) {
@@ -443,11 +503,18 @@ function generateReport(){
443503 mainLogger . info ( `Original time: ${ ( dataArray [ dataArray . length - 1 ] . timestamp - dataArray [ 0 ] . timestamp ) / 1000 } seconds. Original rps: ${ ( 1000 * dataArray . length / ( dataArray [ dataArray . length - 1 ] . timestamp - dataArray [ 0 ] . timestamp ) ) . toFixed ( 4 ) } . Replay rps: ${ ( ( numberOfSuccessfulEvents + numberOfFailedEvents ) * 1000 / ( finishTime - startTime ) ) . toFixed ( 4 ) } . Ratio: ${ args . ratio } .` ) ;
444504 if ( args . dateStats ) {
445505 if ( dateStats . timestamp . length > 0 ) {
506+ mainLogger . info ( `First timestamps: ${ JSON . stringify ( getPercentileTimestamp ( dateStats . timestamp ) ) } ` ) ;
446507 mainLogger . info ( `Last timestamps: ${ JSON . stringify ( getPercentileTimestamp ( dateStats . timestamp ) ) } ` ) ;
508+ mainLogger . info ( `Diff between first and last timestamps: ${ JSON . stringify ( getPercentileDays ( dateStats . timestampDiff , false ) ) } ` ) ;
447509 mainLogger . info ( `Days diff current: ${ JSON . stringify ( getPercentileDays ( dateStats . timeDiff ) ) } ` ) ;
448510 mainLogger . info ( `Days diff historical: ${ JSON . stringify ( getPercentileDays ( dateStats . timeDiffHistorical ) ) } ` ) ;
449511 mainLogger . info ( `Number of empty responses for date stats: ${ dateStats . empty } ` ) ;
512+ mainLogger . info ( `Number of requests with limit greater than default (10): ${ dateStats . numberOfRequestsWithLimitGreaterThanDefault } ` ) ;
513+
450514 }
515+ mainLogger . info ( `Number of requests with limit/pageSize greater than default (10): ${ dateStats . numberOfRequestsWithLimitGreaterThanDefault } . Percent: ${ ( 100 * dateStats . numberOfRequestsWithLimitGreaterThanDefault / ( numberOfSuccessfulEvents + numberOfFailedEvents ) ) . toFixed ( 2 ) } %.` ) ;
516+ mainLogger . info ( `Number of requests with number of records less than pageSize/limit: ${ dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize } of ${ dateStats . timestampFirst . length } requests with data. Percent: ${ ( 100 * dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize / dateStats . timestampFirst . length ) . toFixed ( 2 ) } %.` ) ;
517+ mainLogger . info ( `Number of requests with data older than a half year: ${ dateStats . numberOfRequestsWithDataOlderThanAHalfYear } of ${ dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize } requests with number of records less than pageSize/limit. Percent: ${ ( 100 * dateStats . numberOfRequestsWithDataOlderThanAHalfYear / dateStats . numberOfRequestsWithNumberOfRecordsLessThanPageSize ) . toFixed ( 2 ) } %.` ) ;
451518 }
452519 if ( args . stats ) {
453520 const hiddenStats = { } ;
0 commit comments