From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 58BEDA00E6 for ; Thu, 16 May 2019 19:55:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 140255F1F; Thu, 16 May 2019 19:55:24 +0200 (CEST) Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by dpdk.org (Postfix) with ESMTP id E2D7C4CAB for ; Thu, 16 May 2019 19:55:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1558029319; x=1560621319; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sCbbIv/xOw/DWYTaCt6jmAP/dF/zn8swp9Q9wpMlpc0=; b=FRe8Sm/Biurh04AoDH5DdSAezk0EGaMBzTcW+/itY9sfnmWHT3gkONv8XuPikACA 89XcEu+vcX/6L9tSJiVPIzigCOlMo1hFQA3lNTODsG5tWi71e+pZ0Wf/sM9AL3Av O+1Jt663FUWzYZ+xV9ITnZn76vARKBDo0jk+/2AN0Qg=; X-AuditID: c1b4fb3a-6f1ff7000000189f-df-5cdda407f657 Received: from ESESBMB501.ericsson.se (Unknown_Domain [153.88.183.114]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 2E.CB.06303.704ADDC5; Thu, 16 May 2019 19:55:19 +0200 (CEST) Received: from ESESSMB504.ericsson.se (153.88.183.165) by ESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 16 May 2019 19:55:19 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.192) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Thu, 16 May 2019 19:55:19 +0200 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id x4GHtHcu023701; Thu, 16 May 2019 19:55:19 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Thu, 16 May 2019 19:55:06 +0200 Message-ID: <20190516175510.27154-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190516175510.27154-1-mattias.ronnblom@ericsson.com> References: <20190514092046.30808-1-mattias.ronnblom@ericsson.com> <20190516175510.27154-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRmVeSWpSXmKPExsUyM2J7kS77krsxBssOGVncWGVv8e7TdiaL xXfkHJg9fi1YyuqxeM9LJo+ek/OYApijuGxSUnMyy1KL9O0SuDLe3vzLVvBSsOLCv4MsDYyH +boYOTgkBEwk+p6qdDFycQgJHGWUWNHxiQXC+cYocexCEyOEc5FRorPpOJRzmVFi8YE7TF2M nBxsAp4Sk991s4DYIgJCEks/XmYHKWIWaGWU2PGwkRUkISwQKPH9+D+wBhYBVYn9l7eA2bwC ThLblrxnBrElBOQlVm84AGZzCjhLXD1/AKxXSKBa4mfXGqh6QYmTM5+ALWMW0JRo3f6bHcKW l2jeOpsZol5L4v6SL8wTGIVmIWmZhaRlFpKWBYzMqxhFi1OLi3PTjYz0Uosyk4uL8/P08lJL NjECg/vglt9WOxgPPnc8xCjAwajEwxs7526MEGtiWXFl7iFGCQ5mJRHeDe9vxwjxpiRWVqUW 5ccXleakFh9ilOZgURLnjV69J0ZIID2xJDU7NbUgtQgmy8TBKdXAuPT8367vL9QZqr99Yp3a z7Z2wywxrfQQs4KnK8+qtWZ9OBLpul5/9dTkHT9D2TYrRjfXRt3X/HL4sZd16iWrMzNdc0tj NV4H/OCdri5y/ALDnxUbHPKvPZhX+DhIx+lqeuUp1t3Zrb80NO5LWOxSzK5aGqapfy465HJ+ x1W2F2/m5Jrpr3C7r8RSnJFoqMVcVJwIALrMzdRqAgAA Subject: [dpdk-dev] [PATCH v2 2/6] eal: add pseudo-random number generation performance test 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" Add performance test for rte_rand(). Signed-off-by: Mattias Rönnblom --- app/test/Makefile | 1 + app/test/test_rand_perf.c | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 app/test/test_rand_perf.c diff --git a/app/test/Makefile b/app/test/Makefile index 68d6b4fbc..be0f39227 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -73,6 +73,7 @@ SRCS-y += test_reciprocal_division.c SRCS-y += test_reciprocal_division_perf.c SRCS-y += test_fbarray.c SRCS-y += test_external_mem.c +SRCS-y += test_rand_perf.c SRCS-y += test_ring.c SRCS-y += test_ring_perf.c diff --git a/app/test/test_rand_perf.c b/app/test/test_rand_perf.c new file mode 100644 index 000000000..771713757 --- /dev/null +++ b/app/test/test_rand_perf.c @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Ericsson AB + */ + +#include +#include + +#include +#include +#include + +#include "test.h" + +static volatile uint64_t vsum; + +#define ITERATIONS (100000000) + +enum rand_type { + rand_type_64 +}; + +static const char * +rand_type_desc(enum rand_type rand_type) +{ + switch (rand_type) { + case rand_type_64: + return "Full 64-bit [rte_rand()]"; + default: + return NULL; + } +} + +static __rte_always_inline void +test_rand_perf_type(enum rand_type rand_type) +{ + uint64_t start; + uint32_t i; + uint64_t end; + uint64_t sum = 0; + uint64_t op_latency; + + start = rte_rdtsc(); + + for (i = 0; i < ITERATIONS; i++) { + switch (rand_type) { + case rand_type_64: + sum += rte_rand(); + break; + } + } + + end = rte_rdtsc(); + + /* to avoid an optimizing compiler removing the whole loop */ + vsum = sum; + + op_latency = (end - start) / ITERATIONS; + + printf("%s: %"PRId64" TSC cycles/op\n", rand_type_desc(rand_type), + op_latency); +} + +static int +test_rand_perf(void) +{ + rte_srand(42); + + printf("Pseudo-random number generation latencies:\n"); + + test_rand_perf_type(rand_type_64); + + return 0; +} + +REGISTER_TEST_COMMAND(rand_perf_autotest, test_rand_perf); -- 2.17.1