On 10/23/2015 11:42, Matias Elo wrote:
Application crashes if accuracy option is set to zero
(division by zero). Disable statistics printing if accuracy
<= 0.
Signed-off-by: Matias Elo <[email protected]>
---
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 c50ca20..fc60ebe 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -346,41 +346,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;
My comment was not fixed. l2fwd run should return 0 if we think it
worked well, -1 if there was errors (like no packets,
or l2fwd does not operate properly).
Maxim.
}
/**
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp