From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2A85CA046B for ; Fri, 28 Jun 2019 11:01:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 376551B99E; Fri, 28 Jun 2019 11:01:37 +0200 (CEST) Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by dpdk.org (Postfix) with ESMTP id 4E9D81B99A for ; Fri, 28 Jun 2019 11:01:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1561712489; x=1564304489; 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=osiYzTIgt+Sd6qE1DOqagjLt36VM7pB6xHqnDlhu5F4=; b=Ao0CIC0o+g/38N6BKXdpMnHwcd2CjHLmmUc8oPEiPMB/jBnmHdmsHKetvZYNIN32 +YYn2ke2kfgXNwh86z2v9mb+kEswjpVyLE0uKR252YLJ8gTK7gKXRP/avDsqdyvc WzXapyknp4uWH8sdOQK70BjBdtxpbWTMJi4kf0rSftA=; X-AuditID: c1b4fb30-6f5ff70000001814-80-5d15d7696c67 Received: from ESESBMB505.ericsson.se (Unknown_Domain [153.88.183.118]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 3E.97.06164.967D51D5; Fri, 28 Jun 2019 11:01:29 +0200 (CEST) Received: from ESESBMB505.ericsson.se (153.88.183.172) by ESESBMB505.ericsson.se (153.88.183.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 28 Jun 2019 11:01:29 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.188) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Fri, 28 Jun 2019 11:01:29 +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 x5S91SYW019342; Fri, 28 Jun 2019 11:01:29 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , , , , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Fri, 28 Jun 2019 11:01:21 +0200 Message-ID: <20190628090124.16849-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628090124.16849-1-mattias.ronnblom@ericsson.com> References: <20190605104400.24484-1-mattias.ronnblom@ericsson.com> <20190628090124.16849-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKLMWRmVeSWpSXmKPExsUyM2J7mW7mddFYg98nDC1urLK32L6ii83i 3aftTBa3mk+yWSy+I2fx6cEJFgc2j18LlrJ6LN7zksnj2M1p7B49J+cxebzfd5XN48r31YwB bFFcNimpOZllqUX6dglcGbe2fGcueCVV8en+c6YGxs+iXYycHBICJhK/Zj1g6WLk4hASOMoo MWlOOyOE841RYvfaU6wQzkVGibUrbrFBOJcZJaY87mEE6WcT8JSY/K6bBcQWERCSWPrxMjtI EbPANUaJr5deMIMkhAUCJU68PQfUzcHBIqAq0XPABSTMK+AksfHDGUaIO+QlVm84AFbOKeAs 0bW2lx3EFhKolvh54iEbRL2gxMmZT8B2MQtoSrRu/80OYctLNG+dzQxRryVxf8kX5gmMQrOQ tMxC0jILScsCRuZVjKLFqcVJuelGRnqpRZnJxcX5eXp5qSWbGIGRcXDLb4MdjC+fOx5iFOBg VOLhXbBHNFaINbGsuDL3EKMEB7OSCK/kOZFYId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzrvf/F CAmkJ5akZqemFqQWwWSZODilGhjzd2+8Ub+0ZVqAx1cNLTdj9+IaYa7JZ3l+s5YHhlyXe3p8 p80tX4ZbP+OFJ6UwdjM88Wz+PSF3R0toidqr/Rwqbs42dQftg/55Tp61lJ2XSdqrotGR7UlA xrpMdwkB+56n/63/cLpEJ+2b/HbnJ+PYWzsiIxi48jg850yftHndvvBdPz7/vK/EUpyRaKjF XFScCAAfZ5+riAIAAA== Subject: [dpdk-dev] [PATCH v4 2/5] 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 Acked-by: Bruce Richardson --- MAINTAINERS | 1 + app/test/Makefile | 1 + app/test/meson.build | 2 ++ app/test/test_rand_perf.c | 75 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 app/test/test_rand_perf.c diff --git a/MAINTAINERS b/MAINTAINERS index 75775129d..bbec1982c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -231,6 +231,7 @@ Pseudo-random Number Generation M: Mattias Rönnblom F: lib/librte_eal/common/include/rte_random.h F: lib/librte_eal/common/rte_random.c +F: app/test/test_rand_perf.c ARM v7 M: Jan Viktorin 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/meson.build b/app/test/meson.build index 4de856f93..a47e001bf 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -89,6 +89,7 @@ test_sources = files('commands.c', 'test_power_acpi_cpufreq.c', 'test_power_kvm_vm.c', 'test_prefetch.c', + 'test_rand_perf.c', 'test_rcu_qsbr.c', 'test_rcu_qsbr_perf.c', 'test_reciprocal_division.c', @@ -254,6 +255,7 @@ perf_test_names = [ 'pmd_perf_autotest', 'stack_perf_autotest', 'stack_nb_perf_autotest', + 'rand_perf_autotest' ] # All test cases in driver_test_names list are non-parallel 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