Application crashes if accuracy option is set to zero (division by zero). Disable statistics printing if accuracy <= 0.
Signed-off-by: Matias Elo <matias....@nokia.com> --- test/performance/odp_l2fwd.c | 59 +++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index d15ec28..d1a5b07 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -341,41 +341,56 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) * */ static int print_speed_stats(int num_workers, stats_t **thr_stats, - int duration, int timeout) + int duration, int timeout) { - uint64_t pkts, pkts_prev = 0, pps, drops, maximum_pps = 0; - int i, elapsed = 0; + uint64_t pkts = 0; + uint64_t pkts_prev = 0; + uint64_t pps; + uint64_t drops; + uint64_t maximum_pps = 0; + int i; + int elapsed = 0; + int stats_enabled = 0; int loop_forever = (duration == 0); + if (timeout > 0) + stats_enabled = 1; + /* Wait for all threads to be ready*/ odp_barrier_wait(&barrier); do { - pkts = 0; - drops = 0; + if (stats_enabled) { + pkts = 0; + drops = 0; - sleep(timeout); + sleep(timeout); - for (i = 0; i < num_workers; i++) { - pkts += thr_stats[i]->packets; - drops += thr_stats[i]->drops; + for (i = 0; i < num_workers; i++) { + pkts += thr_stats[i]->packets; + drops += thr_stats[i]->drops; + } + pps = (pkts - pkts_prev) / timeout; + if (pps > maximum_pps) + maximum_pps = pps; + printf("%" PRIu64 " pps, %" PRIu64 " max pps, ", pps, + maximum_pps); + + printf(" %" PRIu64 " total drops\n", drops); + + elapsed += timeout; + pkts_prev = pkts; + } else { + sleep(1); + elapsed += 1; } - pps = (pkts - pkts_prev) / timeout; - if (pps > maximum_pps) - maximum_pps = pps; - printf("%" PRIu64 " pps, %" PRIu64 " max pps, ", pps, - maximum_pps); - - printf(" %" PRIu64 " total drops\n", drops); - - elapsed += timeout; - pkts_prev = pkts; } while (loop_forever || (elapsed < duration)); - printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n", - maximum_pps); + if (stats_enabled) + printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n", + maximum_pps); - return pkts > 100 ? 0 : -1; + return 0; } /** -- 1.9.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp