Skip to content

Commit

Permalink
remove latency values if no successful txns in final report (#1290)
Browse files Browse the repository at this point in the history
closes #1065

Signed-off-by: D <d_kelsey@uk.ibm.com>
  • Loading branch information
davidkel committed Apr 6, 2022
1 parent 5f9aa29 commit 66e8386
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/caliper-core/lib/manager/report/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class Report {
resultMap.set('Name', testLabel ? testLabel : 'unknown');
resultMap.set('Succ', results.getTotalSuccessfulTx());
resultMap.set('Fail', results.getTotalFailedTx());
resultMap.set('Max Latency (s)', CaliperUtils.millisToSeconds(results.getMaxLatencyForSuccessful()).toFixed(2));
resultMap.set('Min Latency (s)', CaliperUtils.millisToSeconds(results.getMinLatencyForSuccessful()).toFixed(2));
resultMap.set('Max Latency (s)', results.getTotalSuccessfulTx() > 0 ? CaliperUtils.millisToSeconds(results.getMaxLatencyForSuccessful()).toFixed(2) : '-');
resultMap.set('Min Latency (s)', results.getTotalSuccessfulTx() > 0 ? CaliperUtils.millisToSeconds(results.getMinLatencyForSuccessful()).toFixed(2) : '-');
resultMap.set('Avg Latency (s)', results.getTotalSuccessfulTx() > 0 ? (CaliperUtils.millisToSeconds(results.getTotalLatencyForSuccessful() / results.getTotalSuccessfulTx())).toFixed(2) : '-');

// Send rate
Expand Down
8 changes: 6 additions & 2 deletions packages/caliper-core/test/manager/report/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('report implementation', () => {
it('should set Max Latency to 2DP if available', () => {
const report = new Report();
const txnStats = new TransactionStatisticsCollector();
txnStats.stats.txCounters.totalSuccessful = 100;
txnStats.stats.latency.successful.max = 1232.2;

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

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

it('should set Avg Latency to `-` if no successful transactions', () => {
it('should set Min/Max/Avg Latency to `-` if no successful transactions', () => {
const report = new Report();
const txnStats = new TransactionStatisticsCollector();

txnStats.stats.txCounters.totalSuccessful = 0;
const output = report.getResultValues('myTestLabel', txnStats);
output.get('Avg Latency (s)').should.equal('-');
output.get('Min Latency (s)').should.equal('-');
output.get('Max Latency (s)').should.equal('-');
});

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

0 comments on commit 66e8386

Please sign in to comment.