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 897A2A0559; Mon, 16 Mar 2020 14:39:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 508661C045; Mon, 16 Mar 2020 14:38:44 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 5F3141C02E for ; Mon, 16 Mar 2020 14:38:42 +0100 (CET) IronPort-SDR: hJhoiNIZ9+UQ6Nsfr+ESaAD1a/ZP92FNxqyVyYa0Hx1lIBp2vZRno6HkwHeEqVRJrGe9vJb8nj ETxAD1mOJ3Pw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2020 06:38:41 -0700 IronPort-SDR: /8GVPanzLz0lz0Oe+e++wn8CdUb9Bh5LMxgil7OJUij3LT1GiBJ2KYpQDbKqm4qVwtTkPTVzwS w1+XboM9Cegg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,560,1574150400"; d="scan'208";a="233166937" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by orsmga007.jf.intel.com with ESMTP; 16 Mar 2020 06:38:40 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com Date: Mon, 16 Mar 2020 13:38:29 +0000 Message-Id: <3548e36bfc63583073868c816fef81a20a50f51e.1584360151.git.vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 3/3] test: add dwk perf tests 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 tests for rte_dwk_hash. Signed-off-by: Vladimir Medvedkin --- app/test/test_hash_perf.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index a438eae..f616af1 100644 --- a/app/test/test_hash_perf.c +++ b/app/test/test_hash_perf.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include "test.h" @@ -29,6 +31,8 @@ #define NUM_SHUFFLES 10 #define BURST_SIZE 16 +#define CRC_INIT_VAL 0xdeadbeef + enum operations { ADD = 0, LOOKUP, @@ -669,6 +673,80 @@ fbk_hash_perf_test(void) } static int +dwk_hash_perf_test(void) +{ + struct rte_dwk_hash_params params = { + .name = "dwk_hash_test", + .entries = ENTRIES, + .socket_id = rte_socket_id(), + }; + struct rte_dwk_hash_table *handle = NULL; + uint32_t *keys = NULL; + unsigned indexes[TEST_SIZE]; + uint64_t tmp_val; + uint64_t lookup_time = 0; + unsigned added = 0; + uint32_t key; + uint16_t val; + unsigned i, j; + int ret = 0; + + handle = rte_dwk_hash_create(¶ms); + if (handle == NULL) { + printf("Error creating table\n"); + return -1; + } + + keys = rte_zmalloc(NULL, ENTRIES * sizeof(*keys), 0); + if (keys == NULL) { + printf("fbk hash: memory allocation for key store failed\n"); + return -1; + } + + /* Generate random keys and values. */ + for (i = 0; i < ENTRIES; i++) { + key = (uint32_t)rte_rand(); + val = rte_rand(); + + if (rte_dwk_hash_add(handle, key, rte_hash_crc_4byte(key, + CRC_INIT_VAL), val) == 0) { + keys[added] = key; + added++; + } + } + + for (i = 0; i < TEST_ITERATIONS; i++) { + uint64_t begin; + uint64_t end; + + /* Generate random indexes into keys[] array. */ + for (j = 0; j < TEST_SIZE; j++) + indexes[j] = rte_rand() % added; + + begin = rte_rdtsc(); + /* Do lookups */ + for (j = 0; j < TEST_SIZE; j++) + ret += rte_dwk_hash_lookup(handle, + keys[indexes[j]], + rte_hash_crc_4byte(keys[indexes[j]], + CRC_INIT_VAL), &tmp_val); + + end = rte_rdtsc(); + lookup_time += (double)(end - begin); + } + + printf("\n\n *** DWK Hash function performance test results ***\n"); + if (ret == 0) + printf("Number of ticks per lookup = %g\n", + (double)lookup_time / + ((double)TEST_ITERATIONS * (double)TEST_SIZE)); + + rte_dwk_hash_free(handle); + + return 0; +} + +static int test_hash_perf(void) { unsigned int with_pushes, with_locks; @@ -695,6 +773,9 @@ test_hash_perf(void) if (fbk_hash_perf_test() < 0) return -1; + if (dwk_hash_perf_test() < 0) + return -1; + return 0; } -- 2.7.4