From patchwork Thu Mar 14 13:15:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joyce Kong X-Patchwork-Id: 51184 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B6E824F98; Thu, 14 Mar 2019 14:15:45 +0100 (CET) Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 377854F90; Thu, 14 Mar 2019 14:15:44 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6EC5480D; Thu, 14 Mar 2019 06:15:43 -0700 (PDT) Received: from net-arm-thunderx2.shanghai.arm.com (net-arm-thunderx2.shanghai.arm.com [10.169.40.121]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 92EFE3F614; Thu, 14 Mar 2019 06:15:41 -0700 (PDT) From: Joyce Kong To: dev@dpdk.org Cc: nd@arm.com, jerinj@marvell.com, konstantin.ananyev@intel.com, chaozhu@linux.vnet.ibm.com, bruce.richardson@intel.com, thomas@monjalon.net, hemant.agrawal@nxp.com, honnappa.nagarahalli@arm.com, gavin.hu@arm.com, stable@dpdk.org Date: Thu, 14 Mar 2019 21:15:04 +0800 Message-Id: <1552569304-74817-4-git-send-email-joyce.kong@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552569304-74817-1-git-send-email-joyce.kong@arm.com> References: <1552569304-74817-1-git-send-email-joyce.kong@arm.com> In-Reply-To: <1544672265-219262-2-git-send-email-joyce.kong@arm.com> References: <1544672265-219262-2-git-send-email-joyce.kong@arm.com> Subject: [dpdk-dev] [PATCH v3 3/3] test/rwlock: amortize the cost of getting time X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Instead of getting timestamp per iteration, amortize its overhead can help to get more precise benchmarking results. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Joyce Kong Reviewed-by: Gavin Hu Reviewed-by: Ola Liljedahl Reviewed-by: Ruifeng Wang Signed-off-by: Joyce Kong --- app/test/test_rwlock.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/test/test_rwlock.c b/app/test/test_rwlock.c index f1c5f40..48291c2 100644 --- a/app/test/test_rwlock.c +++ b/app/test/test_rwlock.c @@ -86,9 +86,9 @@ test_rwlock_per_core(__attribute__((unused)) void *arg) static rte_rwlock_t lk = RTE_RWLOCK_INITIALIZER; static volatile uint64_t rwlock_data; -static uint64_t lock_count[RTE_MAX_LCORE] = {0}; +static uint64_t time_count[RTE_MAX_LCORE] = {0}; -#define TIME_MS 100 +#define MAX_LOOP 10000 #define TEST_RWLOCK_DEBUG 0 static int @@ -105,7 +105,7 @@ load_loop_fn(__attribute__((unused)) void *arg) ; begin = rte_rdtsc_precise(); - while (time_diff < hz * TIME_MS / 1000) { + while (lcount < MAX_LOOP) { rte_rwlock_write_lock(&lk); ++rwlock_data; rte_rwlock_write_unlock(&lk); @@ -119,10 +119,10 @@ load_loop_fn(__attribute__((unused)) void *arg) lcount++; /* delay to make lock duty cycle slightly realistic */ rte_pause(); - time_diff = rte_rdtsc_precise() - begin; } - lock_count[lcore] = lcount; + time_diff = rte_rdtsc_precise() - begin; + time_count[lcore] = time_diff * 1000000 / hz; return 0; } @@ -146,11 +146,13 @@ test_rwlock_perf(void) rte_eal_mp_wait_lcore(); RTE_LCORE_FOREACH(i) { - printf("Core [%u] count = %"PRIu64"\n", i, lock_count[i]); - total += lock_count[i]; + printf("Core [%u] cost time = %"PRIu64" us\n", + i, time_count[i]); + total += time_count[i]; } - printf("Total count = %"PRIu64"\n", total); + printf("Total cost time = %"PRIu64" us\n", total); + memset(time_count, 0, sizeof(time_count)); return 0; }