From patchwork Wed Jun 5 10:43:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 54409 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 38E341B9F0; Wed, 5 Jun 2019 12:44:31 +0200 (CEST) Received: from sesbmg23.ericsson.net (sesbmg23.ericsson.net [193.180.251.37]) by dpdk.org (Postfix) with ESMTP id C01641B9B2 for ; Wed, 5 Jun 2019 12:44:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1559731467; x=1562323467; 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=RAcu0KejPxm9PsQwRrT1ncrArElQbJjmyoF3GQyOlYE=; b=UaZQMVX++ZTqNPcevUAJD7oD0+tvB4YiCWvXOMHFKviYmVr+NpIhK+1E1rUseFex m2g3DAo8GNeQ+HgTkeDg+zaPKxvKwqTHMk+TwpQZHkkhQ8QOaHtG1CBkLbVWx4X0 QI/cSuDZpYK34u+S6APsdSG146mjsmhQ7yIpyOE3LjM=; X-AuditID: c1b4fb25-399ff700000029f0-88-5cf79d0b6d67 Received: from ESESSMB504.ericsson.se (Unknown_Domain [153.88.183.122]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id 5C.3A.10736.B0D97FC5; Wed, 5 Jun 2019 12:44:27 +0200 (CEST) Received: from ESESSMB504.ericsson.se (153.88.183.165) by ESESSMB504.ericsson.se (153.88.183.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 5 Jun 2019 12:44:26 +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; Wed, 5 Jun 2019 12:44:26 +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 x55AiQRC025408; Wed, 5 Jun 2019 12:44:27 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , , , , =?utf-8?q?Mattias_R=C3=B6nnblom?= Date: Wed, 5 Jun 2019 12:43:56 +0200 Message-ID: <20190605104400.24484-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605104400.24484-1-mattias.ronnblom@ericsson.com> References: <20190516203529.GA642@bricha3-MOBL.ger.corp.intel.com> <20190605104400.24484-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsUyM2J7lS733O8xBtfOiFncWGVvsX1FF5vF u0/bmSxuNZ9ks1h8R86B1ePXgqWsHov3vGTy6Dk5j8nj/b6rbB5Xvq9mDGCN4rJJSc3JLEst 0rdL4Mq4sfwzY8EioYp7r3kaGL/zdTFyckgImEjMvrOSpYuRi0NI4CijRPfE/WwQzldGid+9 L6EyFxglHq9bzQ7hXGKUeLC1hRmkn03AU2Lyu24WEFtEQEhi6cfLYEXMAnsZJV6tmweWEBYI lFjcMosdxGYRUJE4uWczE4jNK+AkMbdpPTPEIfISqzccALM5BZwlHk/fD1YjJFAtMeFtM1S9 oMTJmU/AZjILaEq0bv/NDmHLSzRvnc0MUa8lcX/JF+YJjEKzkLTMQtIyC0nLAkbmVYyixanF SbnpRsZ6qUWZycXF+Xl6eaklmxiBUXBwy2/VHYyX3zgeYhTgYFTi4X3R/T1GiDWxrLgy9xCj BAezkghv4u0vMUK8KYmVValF+fFFpTmpxYcYpTlYlMR5o1fviRESSE8sSc1OTS1ILYLJMnFw SjUwFku/PPNny4ob2SePaDzZdn1NctnvM0lCl28mP5/zOHZe5tcbU2xe7ezl3qS1ynNqTc+x xe+yLxZUffQNMGYsmRtwz9Kf6W9r4GvB9kMmXlwWHUYyFyf7nvJ2Uzve568w9ekfl2SnG9NW /vq88tOJbTlrrtstXrmjMkKo63NrQf6Gb7UF3R+b9ZRYijMSDbWYi4oTAX/gIrR+AgAA Subject: [dpdk-dev] [PATCH v3 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 Acked-by: Bruce Richardson --- 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);