Skip to content

Commit

Permalink
comparison max number of decimals (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Feb 15, 2022
1 parent e367d24 commit cf94f6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/app/item-detail/calculations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export const roundNumberTwoDecimals = number => {


export const bytesToMbps = (bytes) => {
return roundNumberTwoDecimals(bytes * 8.0E-6);
return bytes * 8.0E-6;
};
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h6 class="card-header bg-transparent">Request Statistics <span class="compare">
<mfDefaultSorter by="samples">samples</mfDefaultSorter>
</th>
<th scope="col" class="hd jtl-head-color">
<mfDefaultSorter by="avgResponseTime">avg [{{getUnit()}}]</mfDefaultSorter>
<mfDefaultSorter by="avgResponseTime">avg [ms]</mfDefaultSorter>
</th>
<th scope="col" class="hd jtl-head-color">
<mfDefaultSorter by="minResponseTime">min [ms]</mfDefaultSorter>
Expand Down Expand Up @@ -95,32 +95,32 @@ <h6 class="card-header bg-transparent">Request Statistics <span class="compare">
<td>{{_.label}} </td>
<td>{{_.samples}}</td>
<td><span
[className]="comparedData ? _.avgResponseTime > 0 ? 'value-positive' : 'value-negative' : ''">{{_.avgResponseTime}}</span>
[className]="comparedData ? _.avgResponseTime > 0 ? 'value-positive' : 'value-negative' : ''">{{_.avgResponseTime | number: '1.0-2'}}</span>
</td>
<td><span
[className]="comparedData ? _.minResponseTime > 0 ? 'value-positive' : 'value-negative' : ''">{{_.minResponseTime}}</span>
[className]="comparedData ? _.minResponseTime > 0 ? 'value-positive' : 'value-negative' : ''">{{_.minResponseTime | number: '1.0-2'}}</span>
</td>
<td><span
[className]="comparedData ? _.maxResponseTime > 0 ? 'value-positive' : 'value-negative' : ''">{{_.maxResponseTime}}</span>
[className]="comparedData ? _.maxResponseTime > 0 ? 'value-positive' : 'value-negative' : ''">{{_.maxResponseTime | number: '1.0-2'}}</span>
</td>
<td><span [className]="comparedData ? _.n0 > 0 ? 'value-positive' : 'value-negative' : ''">{{_.n0}}</span>
<td><span [className]="comparedData ? _.n0 > 0 ? 'value-positive' : 'value-negative' : ''">{{_.n0 | number: '1.0-2'}}</span>
</td>
<td><span [className]="comparedData ? _.n5 > 0 ? 'value-positive' : 'value-negative' : ''">{{_.n5}}</span>
<td><span [className]="comparedData ? _.n5 > 0 ? 'value-positive' : 'value-negative' : ''">{{_.n5 | number: '1.0-2'}}</span>
</td>
<td><span [className]="comparedData ? _.n9 > 0 ? 'value-positive' : 'value-negative' : ''">{{_.n9}}</span>
<td><span [className]="comparedData ? _.n9 > 0 ? 'value-positive' : 'value-negative' : ''">{{_.n9 | number: '1.0-2'}}</span>
</td>
<td>
<span
[className]="comparedData ? _.throughput > 0 ? 'value-negative' : 'value-positive' : ''">{{_.throughput}}</span>
[className]="comparedData ? _.throughput > 0 ? 'value-negative' : 'value-positive' : ''">{{_.throughput | number: '1.0-2'}}</span>
</td>
<td>
<span
[className]="comparedData ? convertBytesToMbps(_.bytesPerSecond + _.bytesSentPerSecond) > 0 ? 'value-positive' : 'value-negative' : ''">{{convertBytesToMbps(_.bytesPerSecond
+ _.bytesSentPerSecond) || 0 }}</span>
+ _.bytesSentPerSecond) || 0 | number: '1.0-2' }}</span>
</td>
<td>
<span
[className]="comparedData ? _.errorRate > 0 ? 'value-positive' : 'value-negative' : ''">{{_.errorRate}}</span>
[className]="comparedData ? _.errorRate > 0 ? 'value-positive' : 'value-negative' : ''">{{_.errorRate | number: '1.0-2'}}</span>
</td>
<td>
<app-label-health *ngIf="_.statusCodes && _.statusCodes.length > 0" [statusCodes]="_.statusCodes" [responseFailures]="_.responseMessageFailures" [labelName]="_.label" [errorRate]="_.errorRate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ export class RequestStatsCompareComponent implements OnInit, OnDestroy {
minResponseTime: (_.minResponseTime - labelToBeCompared.minResponseTime),
maxResponseTime: (_.maxResponseTime - labelToBeCompared.maxResponseTime),
bytes: ((_.bytes - labelToBeCompared.bytes) / 1024).toFixed(2),
bytesPerSecond: (_.bytesPerSecond - labelToBeCompared.bytesPerSecond),
bytesSentPerSecond:(_.bytesSentPerSecond - labelToBeCompared.bytesSentPerSecond),
n0: (_.n0 - labelToBeCompared.n0),
n5: (_.n5 - labelToBeCompared.n5),
n9: (_.n9 - labelToBeCompared.n9),
errorRate: roundNumberTwoDecimals((_.errorRate - labelToBeCompared.errorRate)),
throughput: roundNumberTwoDecimals((_.throughput - labelToBeCompared.throughput))
errorRate: (_.errorRate - labelToBeCompared.errorRate),
throughput: (_.throughput - labelToBeCompared.throughput)
};
} else {
this.comparisonWarning.push(`${_.label} label not found`);
Expand Down Expand Up @@ -191,6 +193,7 @@ export class RequestStatsCompareComponent implements OnInit, OnDestroy {
this.comparedData = this.labelsData.map((_) => {
const labelToBeCompared = this.comparingData.statistics.find((__) => __.label === _.label);
if (labelToBeCompared) {
console.log(_.bytes, labelToBeCompared)
return {
..._,
avgResponseTime: this.calculatePercDifference(_.avgResponseTime, labelToBeCompared.avgResponseTime),
Expand All @@ -200,6 +203,8 @@ export class RequestStatsCompareComponent implements OnInit, OnDestroy {
n0: this.calculatePercDifference(_.n0, labelToBeCompared.n0),
n5: this.calculatePercDifference(_.n5, labelToBeCompared.n5),
n9: this.calculatePercDifference(_.n9, labelToBeCompared.n9),
bytesPerSecond: this.calculatePercDifference(_.bytesPerSecond, labelToBeCompared.bytesPerSecond),
bytesSentPerSecond:this.calculatePercDifference(_.bytesSentPerSecond, labelToBeCompared.bytesSentPerSecond),
errorRate: this.calculatePercDifference(_.errorRate, labelToBeCompared.errorRate),
throughput: this.calculatePercDifference(_.throughput, labelToBeCompared.throughput)
};
Expand Down Expand Up @@ -245,13 +250,6 @@ export class RequestStatsCompareComponent implements OnInit, OnDestroy {
.toLowerCase();
}

getUnit() {
if (this.comparisonMs) {
return "ms";
}
return "%";
}

focusLabel(label: string) {
this.analyzeChartService.changeMessage({ label });
}
Expand Down

0 comments on commit cf94f6d

Please sign in to comment.