From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41819C4361B for ; Wed, 16 Dec 2020 16:51:19 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 9636F233F8 for ; Wed, 16 Dec 2020 16:51:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9636F233F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8506ACA02; Wed, 16 Dec 2020 17:50:10 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id B7853C9DC for ; Wed, 16 Dec 2020 17:50:04 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 16 Dec 2020 18:49:58 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BGGnvcx005924; Wed, 16 Dec 2020 18:49:58 +0200 From: Ophir Munk To: Ori Kam , dev@dpdk.org, Raslan Darawsheh Cc: Ophir Munk , Thomas Monjalon Date: Wed, 16 Dec 2020 16:49:31 +0000 Message-Id: <20201216164931.1517-7-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201216164931.1517-1-ophirmu@nvidia.com> References: <20201216164931.1517-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v1 6/6] app/regex: replace Linux clock() API with rdtsc 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" Performance measurement (elapsed time and Gbps) are based on Linux clock() API. The resolution is improved by replacing the clock() API with rte_rdtsc_precise() API. Signed-off-by: Ophir Munk --- app/test-regex/main.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/app/test-regex/main.c b/app/test-regex/main.c index f305186..ce0ede2 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -48,8 +48,8 @@ struct qp_params { struct rte_regex_ops **ops; struct job_ctx *jobs_ctx; char *buf; - time_t start; - time_t end; + uint64_t start; + uint64_t cycles; }; struct qps_per_lcore { @@ -326,7 +326,7 @@ run_regex(void *args) unsigned long d_ind = 0; struct rte_mbuf_ext_shared_info shinfo; int res = 0; - double time; + long double time; struct rte_mempool *mbuf_mp; struct qp_params *qp; struct qp_params *qps = NULL; @@ -419,7 +419,7 @@ run_regex(void *args) qp->buf = buf; qp->total_matches = 0; qp->start = 0; - qp->end = 0; + qp->cycles = 0; } for (i = 0; i < nb_iterations; i++) { @@ -432,9 +432,8 @@ run_regex(void *args) update = false; for (qp_id = 0; qp_id < nb_qps; qp_id++) { qp = &qps[qp_id]; - if (!qp->start) - qp->start = clock(); if (qp->total_dequeue < actual_jobs) { + qp->start = rte_rdtsc_precise(); struct rte_regex_ops ** cur_ops_to_enqueue = qp->ops + qp->total_enqueue; @@ -463,24 +462,21 @@ run_regex(void *args) cur_ops_to_dequeue, qp->total_enqueue - qp->total_dequeue); + qp->cycles += + (rte_rdtsc_precise() - qp->start); update = true; - } else { - if (!qp->end) - qp->end = clock(); } - } } while (update); } for (qp_id = 0; qp_id < nb_qps; qp_id++) { - time = ((double)qp->end - qp->start) / CLOCKS_PER_SEC; - printf("Core=%u QP=%u\n", rte_lcore_id(), qp_id + qp_id_base); - printf("Job len = %ld Bytes\n", job_len); - printf("Time = %lf sec\n", time); - printf("Perf = %lf Gbps\n\n", - (((double)actual_jobs * job_len * - nb_iterations * 8) / time) / - 1000000000.0); + qp = &qps[qp_id]; + time = (long double)qp->cycles / rte_get_timer_hz(); + printf("Core=%u QP=%u Job=%ld Bytes Time=%Lf sec Perf=%Lf " + "Gbps\n", rte_lcore_id(), qp_id + qp_id_base, + job_len, time, + (((double)actual_jobs * job_len * nb_iterations * 8) + / time) / 1000000000.0); } if (rgxc->perf_mode) -- 2.8.4