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 CCB62A00E6 for ; Tue, 14 May 2019 11:21:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1E8CC5F13; Tue, 14 May 2019 11:21:41 +0200 (CEST) Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by dpdk.org (Postfix) with ESMTP id D02DB5F0D for ; Tue, 14 May 2019 11:21:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1557825699; x=1560417699; 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=VxUu7LoF8nNLNg+pwXSrVQ/SjxCMXHPzhu3+FZuKYnG2BgmUrDQ2lpnTcP0i45J4 j8QkhIWmujOisf+XEYvfZ9gqEyCrvGCNwsIMMgyiaH+bD16FwFH8vMX7vw12QrvE oOGt8wiMsbMBM/r0P/ad5f8tjPyjPl5umdUl6ULDLOs=; X-AuditID: c1b4fb30-6ddff70000001814-8a-5cda88a3fdbb Received: from ESESSMB503.ericsson.se (Unknown_Domain [153.88.183.121]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id F3.33.06164.3A88ADC5; Tue, 14 May 2019 11:21:39 +0200 (CEST) Received: from ESESBMB504.ericsson.se (153.88.183.171) by ESESSMB503.ericsson.se (153.88.183.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 14 May 2019 11:21:39 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.187) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Tue, 14 May 2019 11:21:39 +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 x4E9LQN6027252; Tue, 14 May 2019 11:21:39 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , , , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Tue, 14 May 2019 11:20:42 +0200 Message-ID: <20190514092046.30808-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514092046.30808-1-mattias.ronnblom@ericsson.com> References: <20190508181014.7dde7580@xps13> <20190514092046.30808-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsUyM2J7pe7ijlsxBpc2yVvcWGVvsX1FF5vF u0/bmSxuNZ9ks1h8R86B1ePXgqWsHov3vGTy6Dk5j8nj/b6rbB5Xvq9mDGCN4rJJSc3JLEst 0rdL4Mp4e/MvW8FLwYoL/w6yNDAe5uti5OSQEDCRmPL0DksXIxeHkMBRRokf17uYIZxvjBI7 fv1ihHAuMkpc3n+UHcK5zCix8NtRJpB+NgFPicnvullAbBEBIYmlHy+DFTEL7GWUeLVuHlhC WMBPYkfbXXYQm0VAVaLx/UtWEJtXwEli7cSbrBCHyEus3nCAGcTmFHCWmDTlFli9kECKxJ+e RywQ9YISJ2c+AbOZBTQlWrf/Zoew5SWat85mhqjXkri/5AvzBEahWUhaZiFpmYWkZQEj8ypG 0eLU4qTcdCMjvdSizOTi4vw8vbzUkk2MwDg4uOW3wQ7Gl88dDzEKcDAq8fCez7gVI8SaWFZc mXuIUYKDWUmEN0rxRowQb0piZVVqUX58UWlOavEhRmkOFiVx3ujVe2KEBNITS1KzU1MLUotg skwcnFINjKGvboT8s1l/02rHgYU/ExdUhK73MXFjOPJhT5PFZq2GmU4/f3zcY3//bGTipEUV tSq5pnf2nTnysemB388tW5/Z3r96Rse5MezEs7STmR6n3vus21Ju+znNSvPrnOPsv5VqmM2W bbKa/KZ9W5A5V2zij0MfSgUftd2S9mT1vFr4k1E78T2v+X4lluKMREMt5qLiRADPkX2bfwIA AA== Subject: [dpdk-dev] [PATCH 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" Message-ID: <20190514092042.JpJBuy89IMfGBk-th2_1mRTRVoz8V1ENH1-vYEuUbJA@z> 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