Skip to content

Commit 66e8386

Browse files
authored
remove latency values if no successful txns in final report (#1290)
closes #1065 Signed-off-by: D <d_kelsey@uk.ibm.com>
1 parent 5f9aa29 commit 66e8386

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/caliper-core/lib/manager/report/report.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ class Report {
156156
resultMap.set('Name', testLabel ? testLabel : 'unknown');
157157
resultMap.set('Succ', results.getTotalSuccessfulTx());
158158
resultMap.set('Fail', results.getTotalFailedTx());
159-
resultMap.set('Max Latency (s)', CaliperUtils.millisToSeconds(results.getMaxLatencyForSuccessful()).toFixed(2));
160-
resultMap.set('Min Latency (s)', CaliperUtils.millisToSeconds(results.getMinLatencyForSuccessful()).toFixed(2));
159+
resultMap.set('Max Latency (s)', results.getTotalSuccessfulTx() > 0 ? CaliperUtils.millisToSeconds(results.getMaxLatencyForSuccessful()).toFixed(2) : '-');
160+
resultMap.set('Min Latency (s)', results.getTotalSuccessfulTx() > 0 ? CaliperUtils.millisToSeconds(results.getMinLatencyForSuccessful()).toFixed(2) : '-');
161161
resultMap.set('Avg Latency (s)', results.getTotalSuccessfulTx() > 0 ? (CaliperUtils.millisToSeconds(results.getTotalLatencyForSuccessful() / results.getTotalSuccessfulTx())).toFixed(2) : '-');
162162

163163
// Send rate

packages/caliper-core/test/manager/report/report.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe('report implementation', () => {
8282
it('should set Max Latency to 2DP if available', () => {
8383
const report = new Report();
8484
const txnStats = new TransactionStatisticsCollector();
85+
txnStats.stats.txCounters.totalSuccessful = 100;
8586
txnStats.stats.latency.successful.max = 1232.2;
8687

8788
const output = report.getResultValues('myTestLabel', txnStats );
@@ -91,18 +92,21 @@ describe('report implementation', () => {
9192
it('should set Min Latency to 2DP if available', () => {
9293
const report = new Report();
9394
const txnStats = new TransactionStatisticsCollector();
95+
txnStats.stats.txCounters.totalSuccessful = 100;
9496
txnStats.stats.latency.successful.min = 232.2;
9597

9698
const output = report.getResultValues('myTestLabel', txnStats);
9799
output.get('Min Latency (s)').should.equal('0.23');
98100
});
99101

100-
it('should set Avg Latency to `-` if no successful transactions', () => {
102+
it('should set Min/Max/Avg Latency to `-` if no successful transactions', () => {
101103
const report = new Report();
102104
const txnStats = new TransactionStatisticsCollector();
103-
105+
txnStats.stats.txCounters.totalSuccessful = 0;
104106
const output = report.getResultValues('myTestLabel', txnStats);
105107
output.get('Avg Latency (s)').should.equal('-');
108+
output.get('Min Latency (s)').should.equal('-');
109+
output.get('Max Latency (s)').should.equal('-');
106110
});
107111

108112
it('should set Avg Latency to 2DP if available', () => {

0 commit comments

Comments
 (0)