aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJanne Peltonen <janne.peltonen@nokia.com>2024-01-16 09:42:04 +0200
committerMatias Elo <matias.elo@nokia.com>2024-01-22 10:38:23 +0200
commit23da2fc78b6e4343f3050743e169a6864c6c9023 (patch)
tree56bc0436a134c6bc340e87e0e9a8d00e6c2849a6 /test
parent91ad7b18d650c66a49987caea3b63e340e3ad2df (diff)
test: dma_perf: fix potential rounding errors and kilo prefix
Use floating point arithmetic when truncation to integer may cause unexpected rounding errors. This also makes sub-second measurement intervals possible. Fix also the kilo prefix (k) in statistics printout. Reviewed-by: Jere Leppänen <jere.leppanen@nokia.com> Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com>
Diffstat (limited to 'test')
-rw-r--r--test/performance/odp_dma_perf.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/test/performance/odp_dma_perf.c b/test/performance/odp_dma_perf.c
index f843843c8..939e1ddaf 100644
--- a/test/performance/odp_dma_perf.c
+++ b/test/performance/odp_dma_perf.c
@@ -1692,7 +1692,7 @@ static void print_humanised(uint64_t value, const char *type)
else if (value > MEGAS)
printf("%.2f M%s\n", (double)value / MEGAS, type);
else if (value > KILOS)
- printf("%.2f K%s\n", (double)value / KILOS, type);
+ printf("%.2f k%s\n", (double)value / KILOS, type);
else
printf("%" PRIu64 " %s\n", value, type);
}
@@ -1702,8 +1702,8 @@ static void print_stats(const prog_config_t *config)
const stats_t *stats;
uint64_t data_cnt = config->num_in_segs * config->src_seg_len, tot_completed = 0U,
tot_tm = 0U, tot_trs_tm = 0U, tot_trs_cc = 0U, tot_trs_cnt = 0U, tot_min_tm = UINT64_MAX,
- tot_max_tm = 0U, tot_min_cc = UINT64_MAX, tot_max_cc = 0U, avg_start_cc, avg_wait_cc,
- avg_tot_tm;
+ tot_max_tm = 0U, tot_min_cc = UINT64_MAX, tot_max_cc = 0U, avg_start_cc, avg_wait_cc;
+ double avg_tot_tm;
printf("\n======================\n\n"
"DMA performance test done\n\n"
@@ -1771,11 +1771,12 @@ static void print_stats(const prog_config_t *config)
stats->trs_cnt > 0U ? stats->trs_cc / stats->trs_cnt : 0U,
stats->trs_cnt > 0U ? stats->min_trs_cc : 0U,
stats->trs_cnt > 0U ? stats->max_trs_cc : 0U);
- print_humanised(stats->completed / (stats->tot_tm / ODP_TIME_SEC_IN_NS),
+ print_humanised(stats->completed /
+ ((double)stats->tot_tm / ODP_TIME_SEC_IN_NS),
"OPS");
printf(" speed: ");
print_humanised(stats->completed * data_cnt /
- (stats->tot_tm / ODP_TIME_SEC_IN_NS), "B/s");
+ ((double)stats->tot_tm / ODP_TIME_SEC_IN_NS), "B/s");
}
avg_start_cc = stats->start_cnt > 0U ? stats->start_cc / stats->start_cnt : 0U;
@@ -1818,7 +1819,7 @@ static void print_stats(const prog_config_t *config)
printf("\n");
}
- avg_tot_tm = tot_tm / config->num_workers / ODP_TIME_SEC_IN_NS;
+ avg_tot_tm = (double)tot_tm / config->num_workers / ODP_TIME_SEC_IN_NS;
printf(" total:\n"
" average time per transfer: %" PRIu64 " (min: %" PRIu64
", max: %" PRIu64 ") ns\n"