diff --git a/src/app/item-detail/item-detail.component.ts b/src/app/item-detail/item-detail.component.ts index bbe9cc04..6f2c5384 100644 --- a/src/app/item-detail/item-detail.component.ts +++ b/src/app/item-detail/item-detail.component.ts @@ -294,33 +294,35 @@ export class ItemDetailComponent implements OnInit { } private calculateThroughputVariability() { - const { overallThroughput, threads } = this.itemData.plot; - const { maxVu, throughput } = this.itemData.overview; - const rampUpIndex = threads.map(_ => _[1]).indexOf(maxVu); + try { + const { overallThroughput, threads } = this.itemData.plot; + const { maxVu, throughput } = this.itemData.overview; + const rampUpIndex = threads.map(_ => _[1]).indexOf(maxVu); + + const throughputValues = overallThroughput.data.slice(rampUpIndex, -2).map(_ => _[1]); + const minThroughput = Math.min(...throughputValues); + const minThroughputIndex = throughputValues.indexOf(minThroughput); + const maxBandIndex = throughputValues.length; + const bandTo = minThroughputIndex + 5 <= maxBandIndex ? minThroughputIndex + 3 : maxBandIndex; + const throughputBandValues = [ + overallThroughput.data.slice(rampUpIndex)[minThroughputIndex - 3][0], + overallThroughput.data.slice(rampUpIndex)[bandTo][0] + ]; + const throughputVariability = this.roundNumberTwoDecimals(100 - (minThroughput / throughput) * 100); - const throughputValues = overallThroughput.data.slice(rampUpIndex, -2).map(_ => _[1]); - if (throughputValues.length === 0) { + return { + value: throughputVariability, + failed: throughputVariability > 20, + bandValues: throughputBandValues + }; + } catch (error) { return { value: null, failed: false, bandValues: [] }; } - const minThroughput = Math.min(...throughputValues); - const minThroughputIndex = throughputValues.indexOf(minThroughput); - const maxBandIndex = throughputValues.length; - const bandTo = minThroughputIndex + 5 <= maxBandIndex ? minThroughputIndex + 3 : maxBandIndex; - const throughputBandValues = [ - overallThroughput.data.slice(rampUpIndex)[minThroughputIndex - 3][0], - overallThroughput.data.slice(rampUpIndex)[bandTo][0] - ]; - const throughputVariability = this.roundNumberTwoDecimals(100 - (minThroughput / throughput) * 100); - - return { - value: throughputVariability, - failed: throughputVariability > 20, - bandValues: throughputBandValues - }; + } bytesToMbps(bytes) {